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

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.

主站蜘蛛池模板: 澳门| 嘉鱼县| 敖汉旗| 包头市| 沐川县| 金平| 宁远县| 白水县| 汾西县| 通城县| 漳平市| 苍溪县| 镇巴县| 临夏市| 大连市| 贵港市| 增城市| 罗平县| 永胜县| 大理市| 怀远县| 沅江市| 舞钢市| 郸城县| 乌审旗| 青河县| 焉耆| 旺苍县| 九台市| 垣曲县| 静安区| 黔西| 淮南市| 梧州市| 富川| 滕州市| 竹北市| 福州市| 嘉禾县| 绵竹市| 五家渠市|