想做一个logo上传,选择图片之后就想把图片显示在logo的位置 替换掉默认的logo
<view class="input">
<image style="width: 100upx;height: 100upx;" :src="logo" @tap="uploadAvatar"></image>
</view>
data(){
return {
logo:"../../../static/img/missing-face.png",}
}
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album'], //从相册选择
success: function (res) {
this.logo = "https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/uni@2x.png";
console.log(JSON.stringify(res));
}
});
动态替换图片地址图像没有变化,在线等,求大腿啊
2 个回复
Trust - 少说废话
this 的指向不对,换成箭头函数,建议补充下基础知识。
x***@163.com (作者)
好的 谢谢哈