1:接收值得一方
<template>
<div style="font-size: 12px;line-height: 60px ;display: flex">
<div style="flex: 1; font-size: 18px">
<span :class="collapseBtnClass" style="cursor: pointer" @click="handleCollapse"></span>
</div>
<el-dropdown style="width: 100px; cursor: pointer">
<span>王小虎</span><i class="el-icon-arrow-down" style="margin-left: 5px"></i>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>个人信息</el-dropdown-item>
<el-dropdown-item>退出</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</template>
<script>
export default {
name: "Header",
props:{
collapseBtnClass:String,
collapse:Function
},
methods: {
handleCollapse() {
if (typeof this.collapse === 'function') {
this.collapse(); // 调用传递过来的函数
}
}
}
}
</script>
<style scoped>
</style>
2:传值得一方
<Aside :isCollapse="isCollapse" :logoTextShow="logoTextShow"></Aside>
<Header :collapseBtnClass = "collapseBtnClass" :collapse="collapse"></Header>