修改data值后watch没有触发
如图显示,我修改msg的值后,没有触发watchconsole.log,我的watch没有写错呀
代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://cdn.bootcss.com/vue/2.6.10/vue.min.js"></script>
</head>
<body>
<div id="app">
{{msg}}
</div>
<script type="text/javascript">
var app=new Vue({
el:'#app',
data:{
msg:'hello vue!!',
},
watch:{
msg:function(newval,oldval){
console.log('newval is:' + newval)
console.log('oldval is:' + oldval)
}
},
computed:{
}
})
</script>
</body>
</html>