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

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.

主站蜘蛛池模板: 正定县| 子长县| 枣庄市| 高雄县| 南和县| 斗六市| 沙田区| 青浦区| 吐鲁番市| 射阳县| 嘉定区| 宿松县| 沙坪坝区| 湖北省| 大厂| 乡城县| 中山市| 普格县| 天等县| 楚雄市| 宁德市| 嘉义县| 兴仁县| 平遥县| 远安县| 临猗县| 呼伦贝尔市| 徐州市| 遵义市| 饶河县| 镇赉县| 襄垣县| 日喀则市| 江达县| 兰溪市| 慈利县| 武山县| 水城县| 富平县| 云和县| 石泉县|