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

v-html

The v-html directive allows you to output content without using the mustache-style curly bracket syntax. It can also be used if your output contains HTML tags – it will render the output as HTML instead of plain text. The value of the HTML attribute is that of the data key or computed function name:

View:

In your view app space, add the v-html attribute to an element:

      <p id="app">
<p v-html="message"></p>
</p>

JavaScript:

In the JavaScript, set the message variable to a string which contains some HTML elements:

      const app = new Vue({
el: '#app',

data: {
message: '<h1>Hello!</h1>'
}
});

You should try and avoid adding HTML to your Vue instance, as it starts to mix up the View in the ViewModel and Model of our MVVM structure. There is also the danger you output an invalid HTML tag inside another. You should only use v-html with data you trust, because using it with an external API could be a security concern as it would allow the API to have control over your application. A potentially malicious API could use v-html to inject undesired content and HTML. Only use v-html with data you can fully trust.

主站蜘蛛池模板: 宁国市| 会昌县| 蓬溪县| 青冈县| 遵化市| 勐海县| 新蔡县| 郸城县| 铁岭县| 洪洞县| 岱山县| 大城县| 临夏市| 中江县| 郧西县| 军事| 泗洪县| 吴堡县| 安阳县| 花莲县| 郎溪县| 阳春市| 兴文县| 叶城县| 磴口县| 南华县| 鹿泉市| 灌南县| 赣州市| 武汉市| 天峨县| 祥云县| 揭东县| 咸阳市| 彩票| 朝阳区| 红桥区| 洛川县| 青铜峡市| 乌兰察布市| 阿尔山市|