- Vue.js 2 Web Development Projects
- Guillaume Chau
- 146字
- 2021-07-02 22:34:25
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.
- Redis入門指南(第3版)
- TensorFlow Lite移動端深度學習
- Vue.js前端開發基礎與項目實戰
- JIRA 7 Administration Cookbook(Second Edition)
- Python測試開發入門與實踐
- Visual C++串口通信技術詳解(第2版)
- Backbone.js Blueprints
- Visual Basic程序設計與應用實踐教程
- Mobile Device Exploitation Cookbook
- Odoo 10 Implementation Cookbook
- Go語言編程
- JSP程序設計實例教程(第2版)
- Orleans:構建高性能分布式Actor服務
- Raspberry Pi Robotic Blueprints
- Python開發基礎