data: {
// 页面初始数据
imageList: [],
},
1、通过for 循环
upLoadImage: function () {
var that = this;
wx.chooseMedia({
count: 9,
mediaType: ['image', 'video'],
sourceType: ['album', 'camera'],
maxDuration: 30,
camera: 'back',
success(res) {
const tempFiles = res.tempFiles;
// 初始化 imageList,如果之前为空的话
if (that.data.imageList.length === 0) {
that.setData({
imageList: tempFiles.map(file => ({
...file,
serverId: null,
serverUrl: null
}))
});
}
for (let