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

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.

主站蜘蛛池模板: 长乐市| 牙克石市| 南雄市| 河津市| 涿鹿县| 澎湖县| 台东市| 华坪县| 夹江县| 富川| 博罗县| 综艺| 潞西市| 保德县| 土默特左旗| 安岳县| 敖汉旗| 曲麻莱县| 治县。| 策勒县| 城固县| 芮城县| 峨眉山市| 横山县| 康定县| 和静县| 南城县| 宜城市| 绵阳市| 文登市| 肇庆市| 项城市| 长泰县| 海盐县| 利辛县| 石泉县| 水富县| 南木林县| 五莲县| 漯河市| 高邑县|