企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## ***.js ``` Page({ data:{ isEmpty:true }, onLoad(){ var image = wx.getStorageSync('image'); if (image){ var imgUrl = image.imgUrl[0]; var isEmpty = image.isEmpty; this.setData({ imgUrl, isEmpty }) } }, click(){ wx.chooseImage({ count: 9, // 默认为9 sizeType: ['original', 'compressed'], // 指定原图或者压缩图 sourceType: ['album', 'camera'], // 指定图片来源 success: (res)=> { var tempFilePaths = res.tempFilePaths wx.setStorageSync('image',{ imgUrl: tempFilePaths, isEmpty: false }); var image = wx.getStorageSync('image'); var imgUrl = image.imgUrl[0]; var isEmpty = image.isEmpty; this.setData({ imgUrl, isEmpty }) } }) } }) ``` ## ***.wxml ``` <view class="my"> <image src="{{isEmpty?'/images/iqiyi.png':imgUrl}}" catchtap='click' mode="aspectFill"></image> <text>A day is a miniature of eternity. </text> </view> ``` ## ***.wxss ``` .scroll-view{ /* width: 100%; */ padding: 20rpx; display: flex; white-space: nowrap; } image{ width: 200px; height: 200px; margin: 30px; border-radius: 50%; } text{ max-width: 300px; text-align: center; line-height: 24px; font-size: 30rpx; } view{ display: flex; justify-content: center; align-items: center; flex-direction: column } ```