xachary
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with
17 additions and
8 deletions
-
src/components/Tree/src/BasicTree.vue
-
src/components/Tree/src/TreeIcon.ts
-
src/components/Tree/src/components/TreeHeader.vue
-
src/components/Tree/style/index.less
-
src/views/demo/tree/index.vue
|
|
@ -402,12 +402,12 @@ |
|
|
const iconDom = icon ? ( |
|
|
const iconDom = icon ? ( |
|
|
<TreeIcon icon={icon} /> |
|
|
<TreeIcon icon={icon} /> |
|
|
) : slots.icon ? ( |
|
|
) : slots.icon ? ( |
|
|
<span class="mr-1">{getSlot(slots, 'icon')}</span> |
|
|
<span class="mr-2">{getSlot(slots, 'icon')}</span> |
|
|
) : null; |
|
|
) : null; |
|
|
|
|
|
|
|
|
item[titleField] = ( |
|
|
item[titleField] = ( |
|
|
<span |
|
|
<span |
|
|
class={`${bem('title')} pl-2`} |
|
|
class={`${bem('title')}`} |
|
|
onClick={handleClickNode.bind(null, item[keyField], item[childrenField])} |
|
|
onClick={handleClickNode.bind(null, item[keyField], item[childrenField])} |
|
|
> |
|
|
> |
|
|
{slots?.title ? ( |
|
|
{slots?.title ? ( |
|
|
|
|
|
@ -6,7 +6,7 @@ import Icon from '@/components/Icon/Icon.vue'; |
|
|
export const TreeIcon = ({ icon }: { icon: VNode | string | undefined }) => { |
|
|
export const TreeIcon = ({ icon }: { icon: VNode | string | undefined }) => { |
|
|
if (!icon) return null; |
|
|
if (!icon) return null; |
|
|
if (isString(icon)) { |
|
|
if (isString(icon)) { |
|
|
return h(Icon, { icon, class: 'mr-1' }); |
|
|
return h(Icon, { icon, class: 'mr-2' }); |
|
|
} |
|
|
} |
|
|
return h(Icon); |
|
|
return h(Icon); |
|
|
}; |
|
|
}; |
|
|
|
|
|
@ -1,5 +1,5 @@ |
|
|
<template> |
|
|
<template> |
|
|
<div :class="bem()" class="flex px-2 py-1.5 items-center"> |
|
|
<div :class="bem()" class="flex mb-1 px-2 py-1.5 items-center"> |
|
|
<slot name="headerTitle" v-if="slots.headerTitle"></slot> |
|
|
<slot name="headerTitle" v-if="slots.headerTitle"></slot> |
|
|
<BasicTitle :helpMessage="helpMessage" v-if="!slots.headerTitle && title"> |
|
|
<BasicTitle :helpMessage="helpMessage" v-if="!slots.headerTitle && title"> |
|
|
{{ title }} |
|
|
{{ title }} |
|
|
|
|
|
@ -3,13 +3,22 @@ |
|
|
.@{tree-prefix-cls} { |
|
|
.@{tree-prefix-cls} { |
|
|
background-color: @component-background; |
|
|
background-color: @component-background; |
|
|
|
|
|
|
|
|
|
|
|
.ant-tree { |
|
|
|
|
|
.ant-tree-checkbox { |
|
|
|
|
|
margin-block-start: 0; |
|
|
|
|
|
margin-inline-start: 4px; |
|
|
|
|
|
margin-inline-end: 4px; |
|
|
|
|
|
|
|
|
|
|
|
& + span { |
|
|
|
|
|
padding-left: 4px; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.ant-tree-node-content-wrapper { |
|
|
.ant-tree-node-content-wrapper { |
|
|
position: relative; |
|
|
position: relative; |
|
|
|
|
|
|
|
|
.ant-tree-title { |
|
|
.ant-tree-title { |
|
|
position: absolute; |
|
|
|
|
|
left: 0; |
|
|
|
|
|
width: 100%; |
|
|
|
|
|
overflow: hidden; |
|
|
overflow: hidden; |
|
|
text-overflow: ellipsis; |
|
|
text-overflow: ellipsis; |
|
|
white-space: nowrap; |
|
|
white-space: nowrap; |
|
|
|
|
|
@ -3,7 +3,7 @@ |
|
|
<Row :gutter="[16, 16]"> |
|
|
<Row :gutter="[16, 16]"> |
|
|
<Col :span="8"> |
|
|
<Col :span="8"> |
|
|
<BasicTree title="基础示例,默认展开第一层" :treeData="treeData" defaultExpandLevel="1"> |
|
|
<BasicTree title="基础示例,默认展开第一层" :treeData="treeData" defaultExpandLevel="1"> |
|
|
<template #icon><SmileTwoTone /></template> |
|
|
<template #icon><SmileTwoTone style="font-size: 16px" /></template> |
|
|
<template #title>666</template> |
|
|
<template #title>666</template> |
|
|
<template #switcherIcon> <CarryOutOutlined /></template> |
|
|
<template #switcherIcon> <CarryOutOutlined /></template> |
|
|
</BasicTree> |
|
|
</BasicTree> |
|
|
|