官术网_书友最值得收藏!

Displaying HTML

Now that we know that text interpolations can't render HTML for security reasons, we will need another way to render dynamic HTML--the v-html directive. Like the v-model directive we saw in Chapter 1, Getting Started with Vue, this is a special attribute that adds a new feature to our template. This one is able to render any valid HTML string into our app. Just pass the string as the value, as follows:

<!-- Preview pane -->
<aside class="preview" v-html="notePreview">
</aside>

Now, the markdown preview should work correctly, and the HTML is dynamically inserted in our page.

Any content inside our aside element will be replaced by the value of the v-html directive. You can use this to put placeholder contents inside.

Here is the result you should have:

There is an equivalent directive for text interpolation, v-text, which behaves like v-html, but escapes the HTML tags just like classic text interpolations.

主站蜘蛛池模板: 宁城县| 静乐县| 永城市| 南澳县| 烟台市| 习水县| 蒙城县| 柳林县| 隆子县| 舒兰市| 兴文县| 东城区| 莱西市| 正定县| 岑溪市| 新绛县| 芜湖市| 日照市| 米易县| 黔南| 阳山县| 合江县| 普格县| 兴隆县| 康平县| 苍梧县| 富民县| 岗巴县| 黄平县| 达日县| 永宁县| 都江堰市| 湟中县| 南岸区| 长寿区| 宝鸡市| 越西县| 新邵县| 乌拉特前旗| 永州市| 鹿邑县|