数据绑定最常见的形式就是使用“Mustache”语法 (双大括号) 的文本插值
1.文本
<p>#文本:{{msg}}</p>
2.原始文本
<p v-html="msg"></p>
3.标签属性
<!--Mustache 语法不能作用在 HTML 特性上,遇到这种情况应该使用 v-bind 指令:-->
<button v-bind:disabled="someDynamicCondition">Button</button>
例子:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
<div id="app1">
<h4>Mustache 标签 : </h4>
<p>#文本:{{msg}}</p>
<p v-once>v-once指令 这个将不会改变: {{ msg }}</p>
</div>
<div id="app2">
<h4>纯文本 v-html 指令</h4>
<p v-html="msg"></p>
</div>
<!--Mustache 语法不能作用在 HTML 特性上,遇到这种情况应该使用 v-bind 指令:-->
<div v-bind:id="dynamicId">123</div>
<div id="app3">
<h4>#属性 v-bind:disabled指令</h4>
<button v-bind:disabled="someDynamicCondition">Button</button>
</div>
</body>
</html>