手摸手从0实现简版Vue —(watch实现)

使用watch有两种方法,第一种直接调用vm.$watch,第二种是在选项中配置watch属性。 watch: { msg: { handler: function (newValue, oldValue) { console.log('watch:', { newValue, oldValue }) }, immediate: true } } // or vm.$watch('msg', function(newVal, oldVal...