<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!--//导入js包-->
<script src="js/vue.js"></script>
<!-- Bootstrap -->
<link href="./bootstrap/dist/css/bootstrap.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.1"></script>
<link href="./css/Animate.css" rel="stylesheet">
<!-- 引入路由 -->
<script src="./js/vue-router.js"></script>
<!-- 位router-link设置样式 -->
</head>
<body>
<div id="app">
<input type="text" v-model="name">
<input type="text" v-model="age">
</div>
<script>
new Vue({
el:'#app',
data:{
name:'',
age:'12'
},
methods: {
},
watch: {
//监听data中的数据,name就是数据的名称
name:function(){
this.age='sdsf'
}
}
})
</script>
</body>
</html>
Vue中监视文本框数据改变之watch方式
最新推荐文章于 2024-07-04 09:12:24 发布