Vue内置API
- 子组件
this.$emit('toTakeoutMethods', index)
- 父组件
<tabs @toTakeoutMethods="func"></tabs>
func(data){
this.activeIndex = data
console.log(data);
}
Uni-app 内置API
- 子组件
uni.$emit('toFather', index)
- 父组件
要在onLoad() 中写
uni.$on('toFather', res => {
this.activeIndex = res
console.log(res);
})
this.$parent 方式
- 子组件
this.$parent.toFatherMethods(index)
- 父组件
toFatherMethods(index){
this.activeIndex = index
console.log(index);
}