Vue在页面中使用watch监听某个变量的值变化
<template>
<div>
<input type="text" v-model="msg" value="" />
{{msg}}
<router-link :to="{name:'HelloWorld'}">连接到第一个</router-link>
</div>
</template>
<script>
export default{
data(){
return{
msg:"Hello"
}
},
methods:{
SayHello(){
console.log("Hello ");
}
},
watch:{
msg:function(){
console.log("RES="+this.msg);
}
}
}
</script>
<style>
</style>