PageMain 组件增加 title slot 设置

This commit is contained in:
hooray
2022-06-19 20:55:32 +08:00
parent e9d7f88be2
commit f730295b35
2 changed files with 15 additions and 2 deletions
+6 -2
View File
@@ -14,8 +14,9 @@ const props = defineProps({
}
})
const collaspeData = ref(props.collaspe)
const titleSlot = !!useSlots().title
const collaspeData = ref(props.collaspe)
function unCollaspe() {
collaspeData.value = false
}
@@ -30,7 +31,10 @@ function unCollaspe() {
'height': collaspeData ? height : ''
}"
>
<div v-if="title" class="title-container">{{ title }}</div>
<div v-if="titleSlot || title" class="title-container">
<slot v-if="titleSlot" name="title" />
<template v-else>{{ title }}</template>
</div>
<slot />
<div v-if="collaspeData" class="collaspe" title="展开" @click="unCollaspe">
<el-icon>
@@ -15,6 +15,15 @@
<page-main title="你可以设置一个自定义的标题">
这里放页面内容
</page-main>
<page-main>
<template #title>
<div style="display: flex; align-item: center; justify-content: space-between;">
通过 slot 设置标题
<el-button size="small">还可以放置自定义按钮</el-button>
</div>
</template>
这里放页面内容
</page-main>
<el-row :gutter="20" style="margin: -10px 10px;">
<el-col :md="8">
<page-main style="margin: 10px 0;">