用v-html:{
{msg}}
另外,介绍一下v-text和v-html的使用方式以及它们之间的区别:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<div id="app">
<p v-text="msg"></p>
<p v-html="msg"></p>
<p>{
{msg}}</p>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
<script>
new Vue({
el: "#app",
data: {
msg: "Hello Vue",
},
});
</script>
</body>
</html>
打印结果:console.log(msg)
Hello Vue
Hello Vue
Hello Vue
<!DOCTYPE html>
<html lang=
版权声明:本文为W_8821原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。