diff --git a/examples/sites/demos/apis/tree-menu.js b/examples/sites/demos/apis/tree-menu.js
index 3156c6841..ec0e59e7a 100644
--- a/examples/sites/demos/apis/tree-menu.js
+++ b/examples/sites/demos/apis/tree-menu.js
@@ -397,6 +397,17 @@ export default {
},
mode: ['pc'],
pcDemo: 'text-wrap'
+ },
+ {
+ name: 'clearable',
+ type: 'boolean',
+ defaultValue: 'false',
+ desc: {
+ 'zh-CN': '搜索框是否可清空',
+ 'en-US': 'Can the search box be cleared'
+ },
+ mode: ['pc'],
+ pcDemo: 'clearable'
}
],
events: [
diff --git a/examples/sites/demos/pc/app/tree-menu/clearable-composition-api.vue b/examples/sites/demos/pc/app/tree-menu/clearable-composition-api.vue
new file mode 100644
index 000000000..91c528468
--- /dev/null
+++ b/examples/sites/demos/pc/app/tree-menu/clearable-composition-api.vue
@@ -0,0 +1,192 @@
+
+
Event description
\nnode-click: Listen for events when a node is clicked.
\ncurrent-change: Listen for events where the currently selected node changes.
\nnode-expand: Listen for events that node expands.
\nnode-collapse: Listen for events when a node is folded up.
\ncheck-change: When checked, listen for events related to changes in checked nodes.
\nclearable
属性来标明是否允许显示搜索框清空按钮',
+ 'en-US':
+ 'Indicate whether to allow the search box clear button to be displayed by setting theclearable
property'
+ },
+ codeFiles: ['clearable.vue']
}
]
}
diff --git a/packages/renderless/src/tree-menu/vue.ts b/packages/renderless/src/tree-menu/vue.ts
index fb0db4574..eec8857dd 100644
--- a/packages/renderless/src/tree-menu/vue.ts
+++ b/packages/renderless/src/tree-menu/vue.ts
@@ -91,7 +91,8 @@ export const renderless = (
treeStyle: computed(() => api.computedTreeStyle()),
defaultExpandedKeys: computed(() =>
props.defaultExpandedKeys && props.defaultExpandedKeys.length ? props.defaultExpandedKeys : state.currentKey
- )
+ ),
+ clearable: computed(() => props.clearable)
})
Object.assign(api, {
diff --git a/packages/renderless/types/tree-menu.type.ts b/packages/renderless/types/tree-menu.type.ts
index 981e17501..7fa04a2eb 100644
--- a/packages/renderless/types/tree-menu.type.ts
+++ b/packages/renderless/types/tree-menu.type.ts
@@ -1,4 +1,4 @@
-import type { ExtractPropTypes } from 'vue'
+import type { ComputedRef, ExtractPropTypes } from 'vue'
import type { treeMenuProps } from '@/tree-menu/src'
import type {
initData,
@@ -31,6 +31,7 @@ export interface ITreeMenuState {
data?: unknown[]
filterText: string
isCollapsed: boolean
+ clearable: ComputedRef