Vue中解析html标签
vue中不解析html标签,会把html标签给正常输出,vue中提供了v-html来解决这一问题正常情况下输出:<!DOCTYPE html><html lang="zh"><head><meta charset="UTF-8"><t
·
vue中不解析html标签,会把html标签给正常输出,vue中提供了v-html来解决这一问题
正常情况下输出
:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<script src="http://www.jq22.com/jquery/jquery-3.3.1.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://cdn.bootcss.com/vue-resource/1.5.1/vue-resource.js"></script>
<body>
<form id="app5">
<p>{{datas}}</p>
</form>
</body>
<script>
var app5 = new Vue({
el: '#app5',
data: {
datas:'<h1>富强、民主、文明、和谐</h1><br/><h2><font color="red">自由、平等、公正、法治</font></h2><br/><h3><font color="blue">爱国、敬业、诚信、友善</font></h3>'
}
});
</script>
</html>
使用v-html
:
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<script src="http://www.jq22.com/jquery/jquery-3.3.1.js"></script>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://cdn.bootcss.com/vue-resource/1.5.1/vue-resource.js"></script>
<body>
<form id="app5">
<p v-html="datas"></p>
</form>
</body>
<script>
var app5 = new Vue({
el: '#app5',
data: {
datas:'<h1>富强、民主、文明、和谐</h1><br/><h2><font color="red">自由、平等、公正、法治</font></h2><br/><h3><font color="blue">爱国、敬业、诚信、友善</font></h3>'
}
});
</script>
</html>
更多推荐
已为社区贡献1条内容
所有评论(0)