forked from tusen-ai/naive-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tree): add
show-line
prop (tusen-ai#4842)
* feat(n-tree): `n-tree` adds `show-line` prop * fix: docs error --------- Co-authored-by: lijiaheng <lijiaheng@semi-tech.com> Co-authored-by: 07akioni <07akioni2@gmail.com>
- Loading branch information
1 parent
3ed6557
commit 9251ca5
Showing
8 changed files
with
143 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<markdown> | ||
# Show Line | ||
</markdown> | ||
|
||
<template> | ||
<n-space vertical> | ||
<n-switch v-model:value="showLine" /> | ||
<n-tree | ||
:show-line="showLine" | ||
:default-expanded-keys="defaultExpandedKeys" | ||
:data="data" | ||
checkable | ||
expand-on-click | ||
selectable | ||
/> | ||
</n-space> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, ref } from 'vue' | ||
import { repeat } from 'seemly' | ||
import { TreeOption } from 'naive-ui' | ||
function createData (level = 4, baseKey = ''): TreeOption[] | undefined { | ||
if (!level) return undefined | ||
return repeat(6 - level, undefined).map((_, index) => { | ||
const key = '' + baseKey + level + index | ||
return { | ||
label: createLabel(level), | ||
key, | ||
children: createData(level - 1, key) | ||
} | ||
}) | ||
} | ||
function createLabel (level: number): string { | ||
if (level === 4) return '道生一' | ||
if (level === 3) return '一生二' | ||
if (level === 2) return '二生三' | ||
if (level === 1) return '三生万物' | ||
return '' | ||
} | ||
export default defineComponent({ | ||
setup () { | ||
return { | ||
showLine: ref(false), | ||
data: createData(), | ||
defaultExpandedKeys: ref(['40', '4030', '403020']) | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<markdown> | ||
# 连接线 | ||
</markdown> | ||
|
||
<template> | ||
<n-space vertical> | ||
<n-switch v-model:value="showLine" /> | ||
<n-tree | ||
:show-line="showLine" | ||
:default-expanded-keys="defaultExpandedKeys" | ||
:data="data" | ||
checkable | ||
expand-on-click | ||
selectable | ||
/> | ||
</n-space> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, ref } from 'vue' | ||
import { repeat } from 'seemly' | ||
import { TreeOption } from 'naive-ui' | ||
function createData (level = 4, baseKey = ''): TreeOption[] | undefined { | ||
if (!level) return undefined | ||
return repeat(6 - level, undefined).map((_, index) => { | ||
const key = '' + baseKey + level + index | ||
return { | ||
label: createLabel(level), | ||
key, | ||
children: createData(level - 1, key) | ||
} | ||
}) | ||
} | ||
function createLabel (level: number): string { | ||
if (level === 4) return '道生一' | ||
if (level === 3) return '一生二' | ||
if (level === 2) return '二生三' | ||
if (level === 1) return '三生万物' | ||
return '' | ||
} | ||
export default defineComponent({ | ||
setup () { | ||
return { | ||
showLine: ref(false), | ||
data: createData(), | ||
defaultExpandedKeys: ref(['40', '4030', '403020']) | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters