使用v-html绑定数据,实现图片的动态转换

首先定义存放图片的div在div里设置v-html事件

<div class="detail-picture" id="picture" v-html="pict"></div>

然后在下面的的js里设定触发事件,例如按钮的点击事件等。在监听函数里写入以下代码,当需要改变图片时,只需要对piv_url的值进行修改即可。

var pict_url = "'https://arcgis.github.io/arcgis-samples-javascript/sample-data/featurelayer-collection/photo-1.jpg'"
this.pict = "<img src="+ pict_url  + " style='height:100%;width:100%;'>"          

 

posted on 2021-08-31 08:59  一往无前!  阅读(382)  评论(0编辑  收藏  举报