mustache 内容渲染 使用mustache语法{{变量}}进行渲染操作,它将会从Vue实例中查找这个变量。 <body> <div id="app">
mustache
<body>
<div id="app">
<p>{{ msg }}</p>
</div>
<script src="./vue.js"></script>
<script>
const app = new Vue({
el: "#app",data: {
msg: "HELLO,WORLD",}
})
</script>
</body>
<body>
<div id="app">
<p>{{ num1 + num2 }}</p>
<p>{{ num1 * num2 }}</p>
<p>{{ num1 - num2 }}</p>
<p>{{ num1 / num2 }}</p>
</div>
<script src="./vue.js"></script>
<script>
const app = new Vue({
el: "#app",data: {
num1: 200,num2: 100,}
})
</script>
</body
Vue指令
<body>
<div id="app">
<p>{{ num1 + num2 }}</p>
<p v-once>{{ num1 + num2 }}</p>
</div>
<script src="./vue.js"></script>
<script>
const app = new Vue({
el: "#app",}
})
</script>
</body>
<body>
<div id="app">
<p v-html="msg"></p>
</div>
<script src="./vue.js"></script>
<script>
const app = new Vue({
el: "#app",data: {
msg:"<a href='http://www.google.com/'>谷歌</a>"
}
})
</script>
</body>
<body>
<div id="app">
<p v-text="msg"></p>
</div>
<script src="./vue.js"></script>
<script>
const app = new Vue({
el: "#app",data: {
msg:"<a href='http://www.google.com/'>谷歌</a>"
}
})
</script>
</body>
<body>
<div id="app">
<p v-show="false">{{msg}}</p>
<p v-show="true">{{msg}}</p>
</div>
<script src="./vue.js"></script>
<script>
const app = new Vue({
el: "#app",data: {
msg:"HELLO,WORLD"
}
})
</script>
</body>
<body>
<div id="app">
<p v-pre>{{msg}}</p>
<p>{{msg}}</p>
</div>
<script src="./vue.js"></script>
<script>
const app = new Vue({
el: "#app",WORLD"
}
})
</script>
</body>
<style>
[v-cloak]{
display: none;
}
</style>
<body>
<div id="app">
<p v-cloak>{{msg}}</p>
</div>
<script src="./vue.js"></script>
<script>
setTimeout(() => {
const app = new Vue({
el: "#app",WORLD"
}
})
},3000)
</script>
</body>