小企业管理,滚山虫,单身部落下载
本文介绍了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
<firstcomponent :name="name"></firstcomponent> import firstcomponent from './component/firstcomponent.vue' export default { data () { return { msg: 'hello vue!', name:'lili' } }, components: { firstcomponent} }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
VUE+elementui组件在table-cell单元格中绘制微型echarts图
Vue通过getAction的finally来最大程度避免影响主数据呈现问题
vue 路由懒加载中给 Webpack Chunks 命名的方法
网友评论