(以下代码用的chooseMedia,for提取的tempFilePath,麻烦老师指导下。)
onChooseImage(){
// 还能再选几张图片
let max = MAX_IMG_NUM - this.data.images.length;
wx.chooseMedia({
count: max,
mediaType: [‘image’, ‘video’],
sourceType: [‘album’, ‘camera’],
maxDuration: 30,
camera: ‘back’,
success: (res)=>{
var abc=[];
for(let i=0;i<res.tempFiles.length;i++){
abc[i]=res.tempFiles[i].tempFilePath
};
console.log(res);
// for(let i=0;i<this.count;i++){
// console.log(res.tempFiles[i].tempFilePath);
this.setData({
images: this.data.images.concat(abc)
// images: this.data.images.concat(res.tempFiles)
})
// 还能再选几张图片
max = MAX_IMG_NUM - this.data.images.length
this.setData({
selectPhoto: max <= 0 ? false : true
})