为了输出真正的 HTML,你需要使用 v-html 指令

        <div id="example">
            {{ a }}
            <span v-once>这个将不会改变: {{ a }}</span>
            <p>Using mustaches: {{ rawHtml }}</p>
            <p>Using v-html directive: <span v-html="rawHtml"></span></p>
        </div>


     <script>
var vm = new Vue({
    el:'#example',
  data: {
    a: 1,
    rawHtml:'<a href="www.baidu.com">baidu</a>'
  }
})
    </script>

Using mustaches: <a href="www.baidu.com">baidu</a>

Using v-html directive: baidu

 

posted @ 2017-12-11 16:41  sky20080101  阅读(278)  评论(0)    收藏  举报