hUploadImage.vue 880 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <view class="">
  3. <view class="box flew flew-center flew-align-center border border-radius-10" @click="uploadImage" v-if="imageVlaue == ''">
  4. <text style="font-size: 60rpx;color: #C0C0C0;">+</text>
  5. </view>
  6. <image class="box dis-block" :src="imageVlaue" mode="" v-else @click="uploadImage"></image>
  7. <text style="color: #EA0606;font-size:30rpx">请上传png/jpg图片,且不超过50MB</text>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. imageVlaue: ''
  15. }
  16. },
  17. methods:{
  18. uploadImage () {
  19. let _that = this
  20. console.log(_that)
  21. uni.chooseImage({
  22. count: 1,
  23. sourceType: 'album ',
  24. success(res){
  25. _that.imageVlaue = res.tempFilePaths[0]
  26. }
  27. })
  28. }
  29. },
  30. mounted() {
  31. this.imageVlaue = ''
  32. }
  33. }
  34. </script>
  35. <style scoped lang="scss">
  36. .box{
  37. width: 120rpx;
  38. height: 120rpx;
  39. }
  40. </style>