vue v-html渲染后,样式不生效


Vue.js官方文档中,对于插值有如下两种写法:

1.文本

  1)<div class="item-head">{{data.head}}</div>

  2)<div v-text="data.head"></div>

2.纯HTML

  1)<div class="item-head">{{data.head}}</div>

 

如果data:{

  head:"this is a item's <em>head</em>, the <em>head's</em> name is red!"

}

两种渲染之后的结果分别是

文本:<div class="item-head">this is a item's <em>head</em>, the <em>head's</em> name is red!</div>

 纯HTML:<div class="item-head">this is a item's head, the head's name is red!</div>

但是发现纯html中的em样式并没有被渲染出来,想了几种可能性,最后问题定位到

尝试去掉style 中 scoped属性后,问题解决
有兄弟在sf中这样解释

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM