perf(card): 扩展 插槽 用法, 新增 title 属性

This commit is contained in:
就眠仪式 2021-10-13 01:17:19 +08:00
parent a5e84081b8
commit fe766d1207
5 changed files with 86 additions and 19 deletions

View File

@ -1,7 +1,7 @@
::: demo ::: demo
<template> <template>
<lay-avatar :src="avatar"></lay-avatar> <lay-avatar :href="href"></lay-avatar>
</template> </template>
<script> <script>
@ -10,10 +10,10 @@ import { ref } from 'vue'
export default { export default {
setup() { setup() {
const avatar = "https://portrait.gitee.com/uploads/avatars/user/2813/8441097_shaynas_1610801433.png" const href = ref("https://portrait.gitee.com/uploads/avatars/user/2813/8441097_shaynas_1610801433.png")
return { return {
avatar href
} }
} }
} }
@ -24,7 +24,7 @@ export default {
::: demo ::: demo
<template> <template>
<lay-avatar :src="avatar" radius></lay-avatar> <lay-avatar :href="avatar" radius></lay-avatar>
</template> </template>
<script> <script>
@ -48,10 +48,10 @@ export default {
::: demo ::: demo
<template> <template>
<lay-avatar :src="avatar" size="xs"></lay-avatar> <lay-avatar :href="avatar" size="xs"></lay-avatar>
<lay-avatar :src="avatar" size="sm"></lay-avatar> <lay-avatar :href="avatar" size="sm"></lay-avatar>
<lay-avatar :src="avatar"></lay-avatar> <lay-avatar :href="avatar"></lay-avatar>
<lay-avatar :src="avatar" size="lg"></lay-avatar> <lay-avatar :href="avatar" size="lg"></lay-avatar>
</template> </template>
<script> <script>

View File

@ -1,6 +1,37 @@
::: demo ::: demo
<template> <template>
<div class="card-container">
<lay-card title="标题">
内容
</lay-card>
</div>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
return {
}
}
}
</script>
<style>
.card-container {
background: whitesmoke;
padding: 20px;
}
</style>
:::
::: demo
<template>
<div class="card-container">
<lay-card> <lay-card>
<template v-slot:header> <template v-slot:header>
标题 标题
@ -9,6 +40,7 @@
内容 内容
</template> </template>
</lay-card> </lay-card>
</div>
</template> </template>
<script> <script>
@ -23,16 +55,22 @@ export default {
} }
</script> </script>
<style>
.card-container {
background: whitesmoke;
padding: 20px;
}
</style>
::: :::
::: demo ::: demo
<template> <template>
<div class="card-container">
<lay-card> <lay-card>
<template v-slot:body>
内容 内容
</template>
</lay-card> </lay-card>
</div>
</template> </template>
<script> <script>
@ -47,11 +85,24 @@ export default {
} }
</script> </script>
<style>
.card-container {
background: whitesmoke;
padding: 20px;
}
</style>
::: :::
<lay-field title="Card attributes" style="margin-top:40px"/> <lay-field title="Card attributes" style="margin-top:40px"/>
| | | | | | | |
| ------ | ---- | ------ | | ------ | ---- | ------ |
| header | 插槽 | `内容` | | title | 标题 | -- |
| body | 插槽 | `内容` |
<lay-field title="Card slots" style="margin-top:40px"/>
| | | |
| ------ | ---- | ------ |
| header | 头部插槽 | -- |
| body | 内容插槽 | -- |

View File

@ -113,9 +113,14 @@ export default {
| ----------- | ------------ | ------- | | ----------- | ------------ | ------- |
| limit | 每页数量 | -- | | limit | 每页数量 | -- |
| total | 总条数 | -- | | total | 总条数 | -- |
| jump | 切换回调 | -- |
| showCount | 显示总数 | `false` | | showCount | 显示总数 | `false` |
| showPage | 显示每页 | `false` | | showPage | 显示每页 | `false` |
| showLimit | 显示每页数量 | `false` | | showLimit | 显示每页数量 | `false` |
| showRefresh | 显示刷新按钮 | `false` | | showRefresh | 显示刷新按钮 | `false` |
| showSkip | 显示跳转 | `false` | | showSkip | 显示跳转 | `false` |
<lay-field title="Page events" style="margin-top:40px"/>
| | | |
| ----------- | ------------ | ------- |
| jump | 切换回调 | -- |

View File

@ -1,6 +1,6 @@
<template> <template>
<img <img
:src="src" :src="href"
class="layui-avatar" class="layui-avatar"
:class="[ :class="[
radius ? 'layui-avatar-radius' : '', radius ? 'layui-avatar-radius' : '',
@ -13,7 +13,7 @@
import { defineProps } from 'vue' import { defineProps } from 'vue'
const props = defineProps<{ const props = defineProps<{
src?: string href?: String
radius?: boolean radius?: boolean
size?: string size?: string
}>() }>()

View File

@ -1,12 +1,23 @@
<template> <template>
<div class="layui-card"> <div class="layui-card">
<div class="layui-card-header"> <div class="layui-card-header" v-if="slot.header || title">
<slot name="header" /> <slot name="header" v-if="slot.header" />
<span v-else>{{ title }}</span>
</div> </div>
<div class="layui-card-body"> <div class="layui-card-body">
<slot name="body" /> <slot name="body" v-if="slot.body" />
<slot v-else></slot>
</div> </div>
</div> </div>
</template> </template>
<script setup name="LayCard" lang="ts"></script> <script setup name="LayCard" lang="ts">
import { useSlots } from 'vue'
const slot = useSlots()
const props =
defineProps<{
title?: string
}>()
</script>