Vue中,子组件和父组件之间,值的改变或者传递,和方法调用

1.子组件改变父组件的值

<father  label="云盘快照" name="name2">
<son :props='rows'   @change="changestate">
</son>
</father >
 
父组件method中        changestate(e){ this.operation = e; }
子组件method中        this.$emit( 'change',传的值this.data.xxx);

1.1.父组件改子组件的值

projectOpera()父组件方法{ this.$refs.child.operationList (子组件中的值)= true; }

2.父传子

父:components: {'b-div': b} // 注册,只能在当前a组件里使用 <b-div :propsname='datas(向子组件传递的参数)'></b-div>

子:<template> <div>{{propsname}}</div> </template>

export default{ props: ['propsname'],

data(){} }

                        

 
 

猜你喜欢

转载自www.cnblogs.com/xu-nian-qin/p/10833438.html