【发布时间】:2019-11-03 11:35:14
【问题描述】:
我有一些字符串变量 log.htmlContent 形式的 html 内容。我将它传递给一个 div 以通过 v-html 显示。仅当 log.htmlContent 包含 img 标签时才会显示此 div(http: 只有在存在 img 标签时才会出现在 log.htmlContent 中)。
<div
v-html="log.htmlContent"
v-if="log.htmlContent.includes('http:')"
class="textContent"
></div>
我想为注入的 img 标签添加一个侦听器,该侦听器将运行一个函数,该函数将 img 标签的 src 内容作为参数传递。这可以用vue吗?如果有怎么办。在此先感谢您的帮助!
【问题讨论】:
标签: typescript vue.js vue-cli