|
[其他]
img 标签的 src 重新赋值,新的图片无法显示
[复制链接]
图片有一个默认的本地图片地址,请后一个后端的接口或者异步的取缓存里面的一个地址, 赋值后 img 标签显示空白(没有显示新的图片);
我尝试着拿到路径后,在动态的创建 img 标签进行渲染也是徒劳
<template><van-image round :src="sketchPhotoSrc" width="50px"></van-image>
<van-image round :src="photoSrc" width="50px"></van-image>
<img :src="photoSrc" alt="" />
<div id="photo" ref="photo"></div></template>
<script>created() {
this.active = "center";
const user = this.$require("user");
user.getUserInfo().then((ret) => {
this.user.name = ret.personName;
this.user.companyName = ret.companys.join();
});
user.userAvatar().then((src) => {
console.log(src);
// 无法显示图片
this.photoSrc =
"https://pic2**.**/30330c345a0343d426981e8eb075e251_xl.jpg";
// 无法显示图片
this.$refs.photo.innerHTML = `<img src="https://pic2**.**/30330c345a0343d426981e8eb075e251_xl.jpg" alt="">`
});
// 可以显示图片
this.sketchPhotoSrc =
"https://static**.**/tukupptphone/common/image/icon_home_new.png";
console.log(this);
},
</script>
|
|