<template>
<view class="">
<button type="default" @click="upload"> 上传图片 </button>
<image v-for="(item,index) in arr" :key="index" :src="item" @click="preventImg(item)"></image>
</view>
</template>
<script>
export default {
data(){
return {
arr:[]
}
},
methods:{
upload(){
let that = this;
uni.chooseImage({
count:3, // h5中无法限定,只能限定单选和多选
success:function(res){
console.log('res',res)
that.arr = res.tempFilePaths;
console.log(that.arr)
}
})
},
preventImg(current){
uni.previewImage({ // 将多张图片按顺序放大预览
current:current,
urls:this.arr
})
}
}
}
</script>
uniapp的上传图片和图片预览
最新推荐文章于 2025-03-21 15:33:22 发布