插值语法
用于解析标签体内容
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="../01/js/vue.js"></script>
</head>
<body>
<div id="root">
<h1>hello,{{name}}</h1>
</div>
<script type="text/javascript">
Vue.config.productionTip = false
new Vue(
{
el:'#root',
data:{
name:'插值语法',
}
}
);
</script>
</body>
</html>
指令语法
用于解析标签
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script type="text/javascript" src="../01/js/vue.js"></script>
</head>
<body>
<div id="root">
<a v-bind href="url">指令语法</a>
</div>
<script type="text/javascript">
Vue.config.productionTip = false
new Vue(
{
el:'#root',
data:{
url:'www.baidu.com'
}
}
);
</script>
</body>
</html>
单项绑定
<inputtype="text"v-bind:value="name">
双向绑定
v-model只能用于输入属性
<inputtype="text"v-model:value="name2">