diff --git a/components/select-tree/SelectTreeHook.js b/components/select-tree/SelectTreeHook.js
index 215a71c3b..9c07780f2 100644
--- a/components/select-tree/SelectTreeHook.js
+++ b/components/select-tree/SelectTreeHook.js
@@ -251,7 +251,7 @@ const SelectTree = ({
* Remote load Data
* @param {*} id click node's id
*/
- const loadNodes = useCallback((id) => {
+ const loadNodes = (id) => {
const _dataSource = typeof dataSource === 'function' ? dataSource(id || '') : dataSource
return HiRequest({
..._dataSource
@@ -267,7 +267,7 @@ const SelectTree = ({
})
return nArr
})
- }, [])
+ }
/**
* 多选模式下复选框事件
* @param {*} checked 是否被选中
diff --git a/components/select-tree/components/tree/NavTree.js b/components/select-tree/components/tree/NavTree.js
index 9277dfb77..ed0346f01 100644
--- a/components/select-tree/components/tree/NavTree.js
+++ b/components/select-tree/components/tree/NavTree.js
@@ -108,48 +108,44 @@ const NavTree = ({
{Object.keys(fullBreadData).length > 0 && (
)}
-
+ {loadingState === 'empty' ? (
+ {localeDatas.selectTree.emptyContent}
+ ) : (
- {loadingState === 'empty' ? (
- -
- {localeDatas.selectTree.emptyContent}
-
- ) : (
- renderData.map((node, index) => {
- const children = getChildrenNodes(node, data)
- const textCls = classNames(
- 'hi-breadtree__text',
- selectedItems.find((n) => n.id === node.id) && 'hi-breadtree__text--selected'
- )
- return (
- -
- {checkable && node.isLeaf ? (
- onCheck(e.target.checked, node)}
- >
- {node.title}
-
- ) : (
- {
- onNodeClick(node, children)
- }}
- >
- {node.title}
-
- )}
- {(children.length > 0 || !node.isLeaf) && (
- onNodeClick(node, children)} />
- )}
-
- )
- })
- )}
+ {renderData.map((node, index) => {
+ const children = getChildrenNodes(node, data)
+ const textCls = classNames(
+ 'hi-breadtree__text',
+ selectedItems.find((n) => n.id === node.id) && 'hi-breadtree__text--selected'
+ )
+ return (
+ -
+ {checkable && node.isLeaf ? (
+ onCheck(e.target.checked, node)}
+ >
+ {node.title}
+
+ ) : (
+ {
+ onNodeClick(node, children)
+ }}
+ >
+ {node.title}
+
+ )}
+ {(children.length > 0 || !node.isLeaf) && (
+ onNodeClick(node, children)} />
+ )}
+
+ )
+ })}
-
+ )}
)
}
diff --git a/components/select-tree/components/tree/style/index.scss b/components/select-tree/components/tree/style/index.scss
index d68871f48..78d62c26e 100644
--- a/components/select-tree/components/tree/style/index.scss
+++ b/components/select-tree/components/tree/style/index.scss
@@ -79,6 +79,10 @@ $tree: 'hi-select-tree' !default;
width: 100%;
display: flex;
flex-direction: column;
+
+ .hi-select-tree--empty {
+ padding: 12px 0 0 12px;
+ }
}
&__list {
diff --git a/docs/demo/select-tree/section-bread.jsx b/docs/demo/select-tree/section-bread.jsx
index a9db2ed4f..7dcc805f2 100644
--- a/docs/demo/select-tree/section-bread.jsx
+++ b/docs/demo/select-tree/section-bread.jsx
@@ -339,8 +339,8 @@ const code = [
return res.map(r => {
return {
...r,
- id: r.code,
- title: r.name
+ id: r.id,
+ title: r.title
}
})
}
@@ -376,16 +376,7 @@ const code = [
method: 'GET',
key: 'id',
params: {pId: key},
- url: 'http://localhost:8001/tree',
- transformResponse: (res) => {
- return res.map(r => {
- return {
- ...r,
- id: r.code,
- title: r.name
- }
- })
- }
+ url: 'http://my-json-server.typicode.com/hiui-group/db/fulldata',
}
}}
/>
diff --git a/docs/demo/select-tree/section-nav.jsx b/docs/demo/select-tree/section-nav.jsx
index a7574d963..0747b7a7b 100644
--- a/docs/demo/select-tree/section-nav.jsx
+++ b/docs/demo/select-tree/section-nav.jsx
@@ -144,12 +144,6 @@ class Demo extends React.Component {
}
}`
const DemoType = () => (
-
+
)
export default DemoType