<view class="img" @click="Choose">
<img :src=ChooseImg alt="">
</view>
<script>
export default {
data() {
return {
ChooseImg: '../ck.png'
};
},
methods: {
Choose() {
uni.chooseImage({
count: 1,
success: (res) => {
console.log(res); // 输出 res 对象,查看其结构和内容
const tempFilePaths = res.tempFilePaths;
if (tempFilePaths && tempFilePaths.length > 0) {
// 显示选择的图片
this.ChooseImg = tempFilePaths[0];
} else {
console.error("No temp file paths found.");
}
},
})
}
},
};
</script>
在uniapp中点击当前图片上传更新图片
最新推荐文章于 2024-07-08 13:59:39 发布