!79 pageHeader组件 特性更新

Merge pull request !79 from 0o张不歪o0/next
This commit is contained in:
就眠儀式 2022-06-20 06:00:35 +00:00 committed by Gitee
commit f877091a24
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 32 additions and 2 deletions

View File

@ -4,7 +4,10 @@
<i class="layui-icon layui-icon-return"></i> <i class="layui-icon layui-icon-return"></i>
<div class="lay-page-header__title">{{ backText }}</div> <div class="lay-page-header__title">{{ backText }}</div>
</div> </div>
<div class="lay-page-header__content">{{ content }}</div> <div class="lay-page-header__content">
<slot v-if="slots.default"></slot>
<template v-else> {{ content }}</template>
</div>
</div> </div>
</template> </template>
@ -14,7 +17,9 @@ export default {
}; };
</script> </script>
<script lang="ts" setup> <script lang="ts" setup>
import { useSlots } from "vue";
import "./index.less"; import "./index.less";
export interface LayPageHeaderProps { export interface LayPageHeaderProps {
content?: string; content?: string;
backText?: string; backText?: string;
@ -25,4 +30,6 @@ const props = withDefaults(defineProps<LayPageHeaderProps>(), {
}); });
const emits = defineEmits(["back"]); const emits = defineEmits(["back"]);
const slots = useSlots();
</script> </script>

View File

@ -38,6 +38,29 @@ const handleBack=()=>{
::: :::
::: title PageHeader 插槽
:::
::: demo 使用 默认插槽可以自定义右侧内容 同时content属性将失效
<template>
<lay-page-header backText="back" @back="handleBack">
<span>Do what ever you want...</span>&nbsp;
<lay-icon type="layui-icon-face-smile" color="red"></lay-icon> &nbsp;
<lay-icon type="layui-icon-face-smile" color="orange"></lay-icon> &nbsp;
<lay-icon type="layui-icon-face-smile" color="green"></lay-icon> &nbsp;
<lay-icon type="layui-icon-face-smile" color="cyan"></lay-icon> &nbsp;
<lay-icon type="layui-icon-face-smile" color="blue"></lay-icon> &nbsp;
<lay-icon type="layui-icon-face-smile" color="black"></lay-icon> &nbsp;
</lay-page-header>
</template>
<script setup>
const handleBack=()=>{
alert('点击返回回调')
}
</script>
:::
::: title PageHeader 属性 ::: title PageHeader 属性
::: :::
@ -46,7 +69,7 @@ const handleBack=()=>{
| 属性 | 描述 | 可选值 | | 属性 | 描述 | 可选值 |
| ------ | ---- | -------------- | | ------ | ---- | -------------- |
| content| 标题 | -- | | content| 标题,当前默认插槽不为空时失效 | -- |
| backText| 返回文本 | 默认 "返回" | | backText| 返回文本 | 默认 "返回" |
::: :::