uni-app上传图片及预览
<view class="imageList flex" v-for="(item,index) in img_url" :key="index"> <view @click="preview(index)">{{item.name}}</view> <view @tap="delImages(index)"> <image style="width: 16px; height: 16px;" src="../../static/del.png"></image> </view> </view>
data(){
img_url: [], img_urlList: [],
},
chosseImg() { uni.chooseImage({ count: 9, //限制图片上传的数量,做多9张 success: res => { //上传成功的回调 for (let i = 0; i < res.tempFiles.length; i++) { this.img_url.push(res.tempFiles[i]) this.img_urlList.push(res.tempFilePaths[i]) } } }) }, /*上传成功预览图片*/ preview(index) { let arr = new Array() arr=this.img_urlList uni.previewImage({ current: index, //当前点击预览的图片 urls: arr //预览图片的链接 }) }, delImages(index) { this.img_url.splice(index, 1) this.img_urlList.splice(index, 1) },