[新增] breadcrumb 组件 separator 属性, 允许自定义分隔符

This commit is contained in:
就眠仪式 2021-10-03 22:24:28 +08:00
parent 2749a35963
commit 6f1aa4e2a5
3 changed files with 44 additions and 3 deletions

View File

@ -21,3 +21,31 @@ export default {
</script> </script>
::: :::
::: demo
<template>
<lay-breadcrumb separator=">">
<lay-breadcrumb-item title="哈哈"></lay-breadcrumb-item>
<lay-breadcrumb-item title="哈哈"></lay-breadcrumb-item>
<lay-breadcrumb-item title="哈哈"></lay-breadcrumb-item>
</lay-breadcrumb>
</template>
<script>
import { ref } from 'vue'
export default {
setup() {
return {
}
}
}
</script>
:::
| | | |
|--|--|--|
| separator | 分割符 | `/` |

View File

@ -5,5 +5,16 @@
</template> </template>
<script setup name="LayBreadcrumb" lang="ts"> <script setup name="LayBreadcrumb" lang="ts">
import { defineProps, provide, withDefaults } from 'vue'
const props = withDefaults(
defineProps<{
separator?: string
}>(),
{
separator: "/"
}
)
provide("separator",props.separator);
</script> </script>

View File

@ -1,15 +1,17 @@
<template> <template>
<a href="">{{title}}</a> <a href="">{{title}}</a>
<span lay-separator="">/</span> <span lay-separator="">{{separator}}</span>
</template> </template>
<script setup name="LayBreadcrumbItem" lang="ts"> <script setup name="LayBreadcrumbItem" lang="ts">
import { defineProps } from 'vue' import { defineProps, inject } from 'vue'
const props = const props =
defineProps<{ defineProps<{
title: string title: string
}>() }>()
const separator = inject("separator");
</script> </script>