DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="huyiwei">
<meta name="generator" content="HBuilder X">
<title>$watch实例方法title>
<script src="lib/vue.js" type="text/javascript" charset="utf-8">script>
head>
<body>
<div id="app">
{{a}}
div>
<script type="text/javascript">
var data = {a:1};
var vm = new Vue({
el:"#app",
data:data
});
vm.$watch('a',function(newVal,oldVal){
console.log(newVal,oldVal);
})
vm.$watch.a = "test...."
script>
body>
html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26