谈到Vue框架,就不得不说Vue的双向绑定。
直接上图:这是一个最简单的例子:
注意:v-model="变量" 只能给具备value属性的元素双向数据绑定!!!
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="app"></div>
<script src="./node_modules/vue/dist/vue.js"></script>
<script>
new Vue({
el:"#app",
template:`<div>
<input type="text" v-model="myvalue"/>
<button v-show="myvalue=='xxxx' " >用户输入的是{{myvalue}}</button>
</div>` ,
data:function(){
return {
myvalue:"12306"
}
}
});
</script>
</body>
</html>