<html>
<head>
</head>
<body>
<div id="app">
<img :src="imgsrc"/>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script>
var vm = new Vue({
el : "-sharpapp",
data : {
img : {}
},
created : function(){
var that = this;
setTimeout(function(){
that.img.src = 100;
},1000);
},
computed : {
imgsrc : function(){
return this.img.src == null ? "www.baidu.com" : "www" + this.img.src;
}
}
});
</script>
</html>
as the direct source code in the figure above, the current scenario is very similar to the above. The two url segments of the img src returned by the background need to be stitched together. If there is no image in the latter paragraph, a default image url is given. The problem now is that whether it is directly: src or computing attributes, it seems that changes in img.src attributes will not affect the calculation of attributes, solution, thank you!