vue——父子组件通信
程序员文章站
2022-07-02 21:24:02
...
组件:
<el-tabs v-model="active" @tab-click="tabClick">
<el-tab-pane v-for="key in tabsList" :key="key.name"></el-tab-pane>
</el-tabs>
export default{
name: 'Tabs',
props:{
tabsList: {
type: Array,
require: true
},
tabClick: {
type: Function,
require: true
}
},
}
引用组件的 .vue
<Tabs :tabsList="tabsList" :tabClick="tabClick"></Tabs>
export default {
name: 'Father',
components: {
Tabs: () => import("@/common/Tabs"),
},
data() {
return {
tabsList: [{label: '用户管理', name: 'user'}, {label: '配置管理', name: 'config'}],
}
},
methods: {
tabClick(tab, event) {
console.log(123);
},
},
}