<body>
<div id="app">
{{getCurrentTime()}}
<br>
{{getCurrentTime1}}
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var v1 = new Vue({
el:"#app",
methods:{
getCurrentTime:function(){
return new Date();
}
},
computed:{
getCurrentTime1:function(){
return new Date();
}
}
})
</script>
</body>
<body>
<div id="app">
<input type="text" v-model="title" />
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var v1 = new Vue({
el:"#app",
data:{
title:"hello vue"
},
watch:{
// title改变就换执行方法
title:function(newValue,oldValue){
console.log(newValue+" :"+oldValue);
}
}
})
</script>
</body>