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

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.

主站蜘蛛池模板: 柏乡县| 台州市| 焉耆| 营口市| 普安县| 长葛市| 邵武市| 石狮市| 鹿泉市| 宁陕县| 滨州市| 大宁县| 中宁县| 永嘉县| 西贡区| 定南县| 石林| 安龙县| 台安县| 潮州市| 元江| 密山市| 璧山县| 保德县| 黎平县| 泽库县| 天气| 天镇县| 鄂伦春自治旗| 通化市| 大余县| 永丰县| 集安市| 汾西县| 武川县| 沙田区| 宝兴县| 太康县| 宜良县| 巴青县| 菏泽市|