Skip to content

Commit 60b1f17

Browse files
author
janrozic1
committed
Add example demonstrating dynamic separator generation in breadcrumbs
Update demo file to showcase a breadcrumb component utilizing a separator generator function, allowing dynamic separator creation based on item index. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 6cc5c7da-6689-4391-8349-0b45bd1c8827 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Event-Id: a866df52-256e-4538-b672-cbe03d4e2c3f Replit-Helium-Checkpoint-Created: true
1 parent 5a213c3 commit 60b1f17

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

components/breadcrumb/demo/separator-indepent.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ title:
88

99
## zh-CN
1010

11-
使用 `Breadcrumb.Separator` 可以自定义分隔符。
11+
使用 `Breadcrumb.Separator` 可以自定义分隔符,也可以传入一个函数来动态生成分隔符
1212

1313
## en-US
1414

1515
The separator can be customized by setting the separator property: `Breadcrumb.Separator`.
16+
You can also pass a generator function that receives the previous item and index to dynamically generate separators.
1617

1718
</docs>
1819

@@ -26,4 +27,19 @@ The separator can be customized by setting the separator property: `Breadcrumb.S
2627
<a-breadcrumb-separator />
2728
<a-breadcrumb-item>An Application</a-breadcrumb-item>
2829
</a-breadcrumb>
30+
31+
<p style="margin: 16px 0">Using a separator generator function:</p>
32+
33+
<a-breadcrumb :separator="separatorGenerator">
34+
<a-breadcrumb-item>Home</a-breadcrumb-item>
35+
<a-breadcrumb-item href="">Dashboard</a-breadcrumb-item>
36+
<a-breadcrumb-item href="">Settings</a-breadcrumb-item>
37+
<a-breadcrumb-item>Profile</a-breadcrumb-item>
38+
</a-breadcrumb>
2939
</template>
40+
41+
<script lang="ts" setup>
42+
import type { SeparatorGeneratorFunc } from '../index';
43+
44+
const separatorGenerator: SeparatorGeneratorFunc = ({ index }) => String(index);
45+
</script>

0 commit comments

Comments
 (0)