File tree Expand file tree Collapse file tree 3 files changed +115
-0
lines changed
components/tree-select/demo Expand file tree Collapse file tree 3 files changed +115
-0
lines changed Original file line number Diff line number Diff line change 1+ <docs >
2+ ---
3+ order: 0
4+ title:
5+ zh-CN: 高亮
6+ en-US: Highlight
7+ ---
8+
9+ ## zh-CN
10+
11+ 搜索值高亮
12+
13+ ## en-US
14+
15+ Search Value Hightlight
16+
17+ </docs >
18+
19+ <template >
20+ <a-tree-select
21+ v-model:value =" value"
22+ v-model:searchValue =" searchValue"
23+ show-search
24+ style =" width : 100% "
25+ :dropdown-style =" { maxHeight: '400px', overflow: 'auto' }"
26+ placeholder =" Please select"
27+ allow-clear
28+ tree-default-expand-all
29+ :tree-data =" treeData"
30+ >
31+ <template #title =" { value: val , title } " >
32+ <b v-if =" val === 'parent 1-1'" style =" color : #08c " >sss</b >
33+ <template v-else >
34+ <template
35+ v-for =" (fragment , i ) in title
36+ .toString ()
37+ .split (new RegExp (` (?<=${searchValue })|(?=${searchValue }) ` , ' i' )) "
38+ >
39+ <span
40+ v-if =" fragment.toLowerCase() === searchValue.toLowerCase()"
41+ :key =" i"
42+ style =" color : #08c "
43+ >
44+ {{ fragment }}
45+ </span >
46+ <template v-else >{{ fragment }}</template >
47+ </template >
48+ </template >
49+ </template >
50+ </a-tree-select >
51+ </template >
52+ <script lang="ts">
53+ import type { TreeSelectProps } from ' ant-design-vue' ;
54+ import { defineComponent , ref , watch } from ' vue' ;
55+ export default defineComponent ({
56+ setup() {
57+ const value = ref <string >();
58+ const treeData = ref <TreeSelectProps [' treeData' ]>([
59+ {
60+ title: ' parent 1' ,
61+ value: ' parent 1' ,
62+ children: [
63+ {
64+ title: ' parent 1-0' ,
65+ value: ' parent 1-0' ,
66+ children: [
67+ {
68+ title: ' my leaf' ,
69+ value: ' leaf1' ,
70+ },
71+ {
72+ title: ' your leaf' ,
73+ value: ' leaf2' ,
74+ },
75+ ],
76+ },
77+ {
78+ title: ' parent 1-1' ,
79+ value: ' parent 1-1' ,
80+ },
81+ ],
82+ },
83+ ]);
84+ watch (value , () => {
85+ console .log (value .value );
86+ });
87+ return {
88+ searchValue: ref (' ' ),
89+ value ,
90+ treeData ,
91+ };
92+ },
93+ });
94+ </script >
Original file line number Diff line number Diff line change 66 <checkable />
77 <suffix />
88 <async />
9+ <Highlight />
910 </demo-sort >
1011</template >
1112<script lang="ts">
@@ -15,6 +16,7 @@ import Multiple from './multiple.vue';
1516import Checkable from ' ./checkable.vue' ;
1617import Suffix from ' ./suffix.vue' ;
1718import Async from ' ./async.vue' ;
19+ import Highlight from ' ./highlight.vue' ;
1820import CN from ' ../index.zh-CN.md' ;
1921import US from ' ../index.en-US.md' ;
2022import { defineComponent } from ' vue' ;
@@ -29,6 +31,7 @@ export default defineComponent({
2931 Checkable ,
3032 Suffix ,
3133 Async ,
34+ Highlight ,
3235 },
3336 setup() {
3437 return {};
Original file line number Diff line number Diff line change 1+ <docs >
2+ ---
3+ order: 12
4+ debug: true
5+ title:
6+ zh-CN: 后缀图标
7+ en-US: Suffix
8+ ---
9+
10+ ## zh-CN
11+
12+ 最简单的用法。
13+
14+ ## en-US
15+
16+ The most basic usage.
17+ </docs >
18+
119<template >
220 <a-space direction =" vertical" style =" width : 100% " >
321 <a-tree-select
You can’t perform that action at this time.
0 commit comments