image.png

代码


<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据绑定之v-html指令</title>
    <script src="https://static.gzj2001.com/vue/vue.js"></script>
</head>
<body>
    <div id="app">
        <div>name</div>
      <div>{{name}}</div>
      <div>{{name2}}</div>
      <!-- 使用v-html输出  识别成html文本-->
      <div v-html="name2"></div>
    </div>
    <script>
        let myapp = new Vue({
            el:"#app",
            data:{
                name:"城南花开",
                name2:"<h1>城南花开博客</h1>"
            }
        })
    </script>
</body>
</html>