本篇文章主要介绍了Vue2.0用 watch 观察 prop 变化(不触发),非常具有实用价值,需要的朋友可以参考下
本文介绍了Vue2.0用 watch 观察 prop 变化(不触发),分享给大家,具体如下:
A 组件:
export default { props:{ name:{ type:String } }, data () { return { author: "Jinkey" } }, mounted:function(){ this.author = 'lili' }, watch:{ name:function(){ console.log(this.name); }, author:function(){ console.log('lili'); } } }
author 有监测到变化,并输出了 lili ; name 由 B 组件传入,却没有监测到,控制台没有输出。
在 B 组件里调用 A 组件,并传值给 name
import firstcomponent from './component/firstcomponent.vue'<a style="color:transparent">来@源gao*daima.com搞@代#码网</a> export default { data () { return { msg: 'Hello Vue!', name:'lili' } }, components: { firstcomponent} }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持gaodaima搞代码网。
以上就是Vue2.0用 watch 观察 prop 变化(不触发)的详细内容,更多请关注gaodaima搞代码网其它相关文章!