代码:
JS:
//获取应用实例
const app = getApp()
Page({
data: {
},
choose(){
var that=this
wx.chooseImage({
count: 9,
sizeType: [‘original’, ‘compressed’],
sourceType: [‘album’],
success: (res) => {
console.log(res)
that.setData({
imgList: res.tempFiles
})
}
})
}
})
WXML:
<!–index.wxml–>
图片个数:{{imgList.length}}
<button style=“height:100rpx;background-color: #FEE126;” bindtap=“choose”> 添加图片</button>
<view class=“Image” wx:for="{{imgList}}" bindtap=‘ViewImage’ data-url="{{imgList[index]}}">
<image class=“Imagecontent1” src=’{{item.path}}’ mode=‘aspectFill’></image>
</view>
真机调试的时候不能正常获取图片个数:{{imgList.length}}
你好,在最新的Nightly版本是正常的,可下载最新的Nightly版本https://developers.weixin.qq.com/miniprogram/dev/devtools/nightly.html