<text class="iconfont">{{selected == item.id ? '' : ''}}</text>
Write it like this, I Able to display the correct iconfont
However,
<text class="iconfont">{{selected == item.id ? item.selIcon : item.nmlIcon}}</text>
Define
nmlIcon in data: '',
selIcon : ''
At this time, I can’t display it
What is the reason for this? Experts, please give me some analysis, thank you!
这是因为在 HTML 放字符串的话,是先浏览器解析 Vue 再得到的,所以到了 Vue 手上就是已经转义了的结果。
{{}}
即v-text
是设置元素的textContent
的,所以不会转义。所以你可以改用
{{{}}}
或者v-html
。