- 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.
- ASP.NET MVC4框架揭秘
- Testing with JUnit
- Rake Task Management Essentials
- C語言程序設計實訓教程
- 從0到1:HTML+CSS快速上手
- C/C++程序員面試指南
- RESTful Java Web Services(Second Edition)
- 深入剖析Java虛擬機:源碼剖析與實例詳解(基礎卷)
- C++20高級編程
- Spring MVC+MyBatis開發從入門到項目實踐(超值版)
- Visual Basic程序設計(第三版)
- 計算機應用基礎項目化教程
- Mastering Concurrency Programming with Java 9(Second Edition)
- Java Web開發基礎與案例教程
- ASP.NET Core and Angular 2