Vue之父子组件之间的传值

父组件,首先要挂载子组件

如果父组件传值给子组件,则

<transition mode="out-in">

<router-view  :applyList='applyList'  applyPath='flightBstrip'></router-view>

</transition>
1.父组件挂载子组件的时候声明属性 applyList,applyPath.(applyList是变量,flightBstrip是字符串)
2.子组件用过  props:['applyList','applyPath'], 调用父组件传过来的值
 
子组件传值
<router-view @select-bstrip-apply="selectBstripApply" ></router-view>
1.父组件挂载子组件的时候声明方法 select-bstrip-apply
2.父组件method中实现selectBstripApply方法
3.子组件中通过
this.$emit("select-bstrip-apply", this.result)来触发父组件中的绑定的select-bstrip-apply事件

猜你喜欢

转载自www.cnblogs.com/jiangshuai0915/p/12230219.html