父组件
引入组件header
<Header @call="call" />
父组件methods添加方法
call(){
console.log("子组件调用了父组件方法")
}
//接受参数写法
//call(type){
// console.log("子组件调用了父组件方法",type)
//}
子组件
页面添加点击事件
<view @click="changeType">调用父组件方法</view>
子组件methods中添加方法,使用$emit调用父组件方法
changeType(){
this.$emit("call")
//传入参数写法
//this.$emit("call",type)
},