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

View File

@@ -1,12 +1,23 @@
<template>
<div class="layui-card">
<div class="layui-card-header">
<slot name="header" />
<div class="layui-card-header" v-if="slot.header || title">
<slot name="header" v-if="slot.header" />
<span v-else>{{ title }}</span>
</div>
<div class="layui-card-body">
<slot name="body" />
<slot name="body" v-if="slot.body" />
<slot v-else></slot>
</div>
</div>
</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>