Skip to content

FaTree ​

Retains ElTree selection, checkboxes, dragging, lazy loading and node operations. Adds a title, an all-nodes entry, filtering, collapsible navigation, label synchronization and asynchronous loading. Height follows the caller or container without an additional mobile minimum height. Card borders use the Element Plus theme.

Basic

Interactive example
View code
Vue
<template>
	<FaTree v-model="value" v-model:label="label" :data="data" title="文档导航" :width="280" @change="handleChange" />
	<p style="margin: 14px 0 0; color: var(--el-text-color-secondary)">
		当前节点:{{ label }}({{ value }});change 数据:{{ JSON.stringify(changedData) }}({{ changeCount }} 次)
	</p>
</template>

<script setup lang="ts">
import { ref } from "vue";

const value = ref<string | number | boolean | object | null>("table");
const label = ref("表格组件");
const changedData = ref<unknown>();
const changeCount = ref(0);
const data = [
	{
		value: "components",
		label: "组件",
		children: [
			{ value: "form", label: "表单组件" },
			{ value: "table", label: "表格组件" },
			{ value: "upload", label: "上传组件" },
		],
	},
	{
		value: "guide",
		label: "开发指南",
		children: [{ value: "install", label: "安装与使用" }],
	},
];

const handleChange = (data: unknown): void => {
	changedData.value = data;
	changeCount.value++;
};
</script>

Checkbox Slots

Interactive example
View code
Vue
<template>
	<FaTree :data="data" title="功能目录" :width="340" show-checkbox draggable>
		<template #label="{ node }"
			><strong>{{ node.label }}</strong></template
		>
		<template #default="{ data: item }"><ElTag v-if="item.disabled" size="small" type="info">禁用</ElTag></template>
	</FaTree>
</template>

<script setup lang="ts">
const data = [
	{
		value: "components",
		label: "组件",
		showQuantity: true,
		quantity: 26,
		children: [
			{ value: "form", label: "表单", showQuantity: true, quantity: 4 },
			{ value: "table", label: "表格", showQuantity: true, quantity: 2 },
			{ value: "upload", label: "上传", disabled: true },
		],
	},
	{ value: "guide", label: "开发指南", showQuantity: true, quantity: 3 },
];
</script>

Async Tree

Interactive example
View code
Vue
<template>
	<div class="demo-stack">
		<ElButton :loading="treeRef?.loading" @click="treeRef?.refresh()">重新请求树数据</ElButton>
		<FaTree ref="treeRef" :request-api="requestApi" title="异步目录" :width="360" />
	</div>
</template>

<script setup lang="ts">
import { useTemplateRef } from "vue";

interface TreeExpose {
	loading: boolean;
	refresh: () => Promise<void>;
}

const treeRef = useTemplateRef<TreeExpose>("treeRef");
let version = 0;
const requestApi = async (): Promise<Record<string, unknown>[]> => {
	await new Promise<void>((resolve) => {
		window.setTimeout(resolve, 400);
	});
	version++;
	return [
		{ value: "components", label: `组件(刷新 ${version})`, children: [{ value: "table", label: "表格" }] },
		{ value: "sdk", label: "SDK", children: [{ value: "net", label: "Fast.NET" }] },
	];
};
</script>

Node Operations

Interactive example
View code
Vue
<template>
	<div class="demo-stack">
		<div class="demo-row">
			<ElButton @click="treeRef?.setCheckedKeys?.(['element'])">选中组件库</ElButton>
			<ElButton @click="treeRef?.append?.({ value: 'admin', label: 'Fast.Admin' }, 'root')">追加节点</ElButton>
			<ElButton @click="treeRef?.remove?.('admin')">删除追加节点</ElButton>
			<ElButton type="primary" @click="readChecked">读取选中 Key</ElButton>
		</div>
		<FaTree ref="treeRef" :data="data" hide-all hide-filter show-checkbox node-key="value" :width="360" />
		<span class="demo-value">选中 Key:{{ checked }}</span>
	</div>
</template>

<script setup lang="ts">
import { ref, useTemplateRef } from "vue";

interface TreeExpose {
	append?: (data: Record<string, unknown>, parent: string) => void;
	getCheckedKeys?: () => unknown[];
	remove?: (key: string) => void;
	setCheckedKeys?: (keys: string[]) => void;
}

const treeRef = useTemplateRef<TreeExpose>("treeRef");
const checked = ref("暂无");
const data = [
	{
		value: "root",
		label: "Fast 系列",
		children: [
			{ value: "element", label: "Fast.Element.Plus" },
			{ value: "net", label: "Fast.NET" },
		],
	},
];

const readChecked = (): void => {
	checked.value = treeRef.value?.getCheckedKeys?.().join("、") || "暂无";
};
</script>

For remote loading, strings and numbers in init-param are passed directly to request-api. For object input, the component merges in the current searchValue. When init-param is omitted or set to null, the request receives an object containing searchValue.

Scalar forwarding takes effect in 2.0.27. The demos on this site use 2.0.27.

FaTree Complete API

Props

EL defaults refer to Element Plus before Fast is imported. 2.14.7

PropertySourceDescriptionTypeDefault
dataFast overrideComponent data.ArrayFast[]EL[]
nodeKeyFast overrideUnique tree-node key.StringFastvalueEL—
defaultExpandAllFast global enhancementExpand all nodes by default.BooleanFasttrueELfalse
checkOnClickNodeFast global enhancementToggle checking when a tree node is clicked.BooleanFasttrueELfalse
propsFast overrideField mappings.ObjectFast{"children":"children","label":"label","disabled":"disabled"}EL{"children":"children","label":"label","disabled":"disabled"}
highlightCurrentFast global enhancementHighlight the current tree node.BooleanFasttrueELfalse
filterNodeMethodFast overrideTree filter; false hides the node.FunctionFast—EL—
disabledFast additionDisable the component or current option.Booleanfalse
collapseOnClickNodeFast additionCollapse expanded siblings when a tree node is clicked.Booleanfalse
modelValueFast additionv-model value.String / Number / Boolean / Objectfalse
labelFast additionDisplay text or synchronized label.String—
widthFast additionComponent width.String / Number180
defaultSelectionFast additionInitially selected tree node value.String / Number—
titleFast additionComponent title.String—
hamburgerFast additionShow tree collapse controls.Booleanfalse
hideAllFast additionHide the tree's All node.Booleanfalse
hideFilterFast additionHide the tree filter input.Booleanfalse
allValueFast additionModel value for the tree's All node.String / Number / Boolean / Objectfalse
requestApiFast additionAsynchronous data-request function.Function—
initParamFast additionInitial request parameters.String / Number / Object—
emptyTextEL nativeEmpty-state text.String—
renderAfterExpandEL nativeRender children only after first expansion.Booleantrue
checkStrictlyEL nativeCheck parent and child nodes independently.Booleanfalse
expandOnClickNodeEL nativeExpand/collapse when node content is clicked.Booleantrue
checkOnClickLeafEL nativeToggle checking when a leaf is clicked.Booleantrue
checkDescendantsEL nativeCheck loaded descendants of a checked parent.Booleanfalse
autoExpandParentEL nativeAutomatically expand parents when expanding a node.Booleantrue
defaultCheckedKeysEL nativeInitially checked node keys.Array—
defaultExpandedKeysEL nativeInitially expanded node keys.Array—
currentNodeKeyEL nativeInitially current node key.String / Number—
renderContentEL nativeCustom tree-node renderer.Function—
showCheckboxEL nativeShow tree-node checkboxes.Booleanfalse
draggableEL nativeAllow dragging.Booleanfalse
allowDragEL nativePredicate allowing a tree node to be dragged.Function—
allowDropEL nativePredicate allowing a dragged node to be dropped at a target.Function—
lazyEL nativeEnable lazy loading.Booleanfalse
loadEL nativeLazy tree-node loader.Function—
accordionEL nativeExpand only one sibling tree node at a time.Booleanfalse
indentEL nativeHorizontal tree-level indentation in pixels.Number18
iconEL nativeIcon component or name.String / Object / Function—

Events

NameSourceDescriptionParameters / type
check-changeEL nativeTree-node selection changes.—
current-changeEL nativeCurrent table row, tree node, or selected value changes.—
node-clickEL nativeTree-node click.—
node-contextmenuEL nativeTree-node context menu.—
node-collapseEL nativeTree node collapses.—
node-expandEL nativeTree node expands.—
checkEL nativeTree checkbox click with node data and checked collections.—
node-drag-startEL nativeTree-node dragging starts.—
node-drag-endEL nativeTree-node dragging ends.—
node-dropEL nativeTree-node drop completes.—
node-drag-leaveEL nativeDragged node leaves a target.—
node-drag-enterEL nativeDragged node enters a target.—
node-drag-overEL nativeDragged node moves over a target.—
update:modelValueFast additionUpdates v-model.—
update:labelFast additionUpdates the label model.—
dataChangeFast additionAsynchronous data loading completes.—
changeFast additionValue or selection changes.—

Slots

NameSourceDescriptionParameters / type
default({ node, data })EL nativeDefault component content.({ node, data })
label({ node, data })Fast additionCustom form, tree-node, or option label.({ node, data })
emptyEL nativeCustom empty-state content.—

Exposes

NameSourceDescriptionParameters / type
filterEL nativeFilters tree nodes by keyword.—
getNodeKeyEL nativeGets a tree node's unique key.—
getNodePathEL nativeGets the data path from root to a node.—
updateKeyChildrenEL nativeUpdates tree/tree-table children by node key.—
getCheckedNodesEL nativeGets checked tree-node data.—
setCheckedNodesEL nativeSets checked nodes by data.—
getCheckedKeysEL nativeGets checked tree-node keys.—
setCheckedKeysEL nativeSets checked nodes by keys.—
setCheckedEL nativeSets a tree node's checked state.—
getHalfCheckedNodesEL nativeGets partially checked tree-node data.—
getHalfCheckedKeysEL nativeGets partially checked tree-node keys.—
getCurrentKeyEL nativeGets the current tree-node key.—
getCurrentNodeEL nativeGets current tree-node data.—
setCurrentKeyEL nativeSets the current tree node by key.—
setCurrentNodeEL nativeSets the current tree node by data.—
getNodeEL nativeGets a tree-node instance by data or key.—
removeEL nativeRemoves a tree node.—
appendEL nativeAppends a tree child.—
insertBeforeEL nativeInserts before a tree node.—
insertAfterEL nativeInserts after a tree node.—
loadingFast additionFast business loading state.—
refreshFast additionRepeats the data request or refreshes business content.—

FaTree instance methods ​

These are call snippets. Use rows, options and fields from your actual data.

filter Filter ​

Filters tree nodes, hiding excluded nodes.

Signature ​

ts
filter(value: FilterValue): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	componentRef.value?.filter(1);
}
</script>

Input ​

InputTypeRequired / defaultDescription
valueanyRequiredForm value, selected value, or filter keyword to set.

Returns ​

ValueTypeDescription
resultvoidNo return value.

getNodeKey Key ​

Gets a node's unique identifier.

Signature ​

ts
getNodeKey(node: import("element-plus/es/components/tree/src/model/node.mjs").default): any;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	const result = componentRef.value?.getNodeKey(row);
	console.log(result);
}
</script>

Input ​

InputTypeRequired / defaultDescription
nodeNodeRequiredElement Plus Tree node instance.

Returns ​

ValueTypeDescription
resultanyMethod result consistent with the current component state.

getNodePath Path ​

Gets path data for the specified node.

Signature ​

ts
getNodePath(data: import("element-plus").TreeKey | TreeNodeData): TreeNodeData[];

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	const result = componentRef.value?.getNodePath(row);
	console.log(result);
}
</script>

Input ​

InputTypeRequired / defaultDescription
dataTreeNodeData | TreeKeyRequiredBusiness data to query, insert, remove, or replace.

Returns ​

ValueTypeDescription
resultTreeNodeData[]Method result consistent with the current component state.

updateKeyChildren Node ​

Sets new data for a node; requires node-key.

Signature ​

ts
updateKeyChildren(key: import("element-plus").TreeKey, data: import("element-plus").TreeData): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" :data="[{ id: 1, label: 'Fast' }]" node-key="id" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	componentRef.value?.updateKeyChildren(1, [{ id: 11, label: "Fast" }]);
}
</script>

Input ​

InputTypeRequired / defaultDescription
keyTreeKeyRequiredUnique node, row, or column identifier.
dataTreeDataRequiredBusiness data to query, insert, remove, or replace.

Returns ​

ValueTypeDescription
resultvoidNo return value.

getCheckedNodes Selection ​

Returns checked nodes when show-checkbox is true.

Signature ​

ts
getCheckedNodes(leafOnly?: boolean, includeHalfChecked?: boolean): TreeNodeData[];

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	const result = componentRef.value?.getCheckedNodes(true, true);
	console.log(result);
}
</script>

Input ​

InputTypeRequired / defaultDescription
leafOnlyboolean | undefinedOptionalWhether to return only leaf nodes.
includeHalfCheckedboolean | undefinedOptionalWhether to include partially checked nodes.

Returns ​

ValueTypeDescription
resultTreeNodeData[]Method result consistent with the current component state.

setCheckedNodes Selection ​

Sets checked nodes; requires node-key.

Signature ​

ts
setCheckedNodes(nodes: import("element-plus/es/components/tree/src/model/node.mjs").default[], leafOnly?: boolean): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	componentRef.value?.setCheckedNodes([row], true);
}
</script>

Input ​

InputTypeRequired / defaultDescription
nodesNode[]RequiredNodes to check.
leafOnlyboolean | undefinedOptionalWhether to return only leaf nodes.

Returns ​

ValueTypeDescription
resultvoidNo return value.

getCheckedKeys Selection ​

Returns checked node keys when show-checkbox is true.

Signature ​

ts
getCheckedKeys(leafOnly?: boolean): import("element-plus").TreeKey[];

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	const result = componentRef.value?.getCheckedKeys(true);
	console.log(result);
}
</script>

Input ​

InputTypeRequired / defaultDescription
leafOnlyboolean | undefinedOptionalWhether to return only leaf nodes.

Returns ​

ValueTypeDescription
resultTreeKey[]Method result consistent with the current component state.

setCheckedKeys Selection ​

Sets checked nodes; requires node-key.

Signature ​

ts
setCheckedKeys(keys: import("element-plus").TreeKey[], leafOnly?: boolean): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	componentRef.value?.setCheckedKeys(["name"], true);
}
</script>

Input ​

InputTypeRequired / defaultDescription
keysTreeKey[]RequiredNode keys to check.
leafOnlyboolean | undefinedOptionalWhether to return only leaf nodes.

Returns ​

ValueTypeDescription
resultvoidNo return value.

setChecked Selection ​

Sets a node's checked state; requires node-key.

Signature ​

ts
setChecked(data: import("element-plus").TreeKey | TreeNodeData, checked: boolean, deep?: boolean): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	componentRef.value?.setChecked(row, true, true);
}
</script>

Input ​

InputTypeRequired / defaultDescription
dataTreeNodeData | TreeKeyRequiredBusiness data to query, insert, remove, or replace.
checkedbooleanRequiredWhether the target node is checked.
deepboolean | undefinedOptionalWhether descendants are included.

Returns ​

ValueTypeDescription
resultvoidNo return value.

getHalfCheckedNodes Selection ​

Returns partially checked nodes when show-checkbox is true.

Signature ​

ts
getHalfCheckedNodes(): TreeNodeData[];

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	const result = componentRef.value?.getHalfCheckedNodes();
	console.log(result);
}
</script>

Input ​

This method has no input parameters.

Returns ​

ValueTypeDescription
resultTreeNodeData[]Method result consistent with the current component state.

getHalfCheckedKeys Selection ​

Returns partially checked node keys when show-checkbox is true.

Signature ​

ts
getHalfCheckedKeys(): import("element-plus").TreeKey[];

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	const result = componentRef.value?.getHalfCheckedKeys();
	console.log(result);
}
</script>

Input ​

This method has no input parameters.

Returns ​

ValueTypeDescription
resultTreeKey[]Method result consistent with the current component state.

getCurrentKey Current ​

Returns current-node data, or null when no node is current.

Signature ​

ts
getCurrentKey(): import("element-plus").TreeKey | null;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	const result = componentRef.value?.getCurrentKey();
	console.log(result);
}
</script>

Input ​

This method has no input parameters.

Returns ​

ValueTypeDescription
resultTreeKey | nullMethod result consistent with the current component state.

getCurrentNode Current ​

Returns current-node data, or null when no node is current.

Signature ​

ts
getCurrentNode(): TreeNodeData | null;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	const result = componentRef.value?.getCurrentNode();
	console.log(result);
}
</script>

Input ​

This method has no input parameters.

Returns ​

ValueTypeDescription
resultTreeNodeData | nullMethod result consistent with the current component state.

setCurrentKey Current ​

Sets the current node by key; requires node-key.

Signature ​

ts
setCurrentKey(key?: import("element-plus").TreeKey | null, shouldAutoExpandParent?: boolean): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
function handleExample() {
	componentRef.value?.setCurrentKey(1, true);
}
</script>

Input ​

InputTypeRequired / defaultDescription
keyTreeKey | null | undefinedOptionalUnique node, row, or column identifier.
shouldAutoExpandParentboolean | undefinedOptionalWhether to automatically expand the target's parents.

Returns ​

ValueTypeDescription
resultvoidNo return value.

setCurrentNode Current ​

Sets the current node; requires node-key.

Signature ​

ts
setCurrentNode(node: import("element-plus/es/components/tree/src/model/node.mjs").default, shouldAutoExpandParent?: boolean): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	componentRef.value?.setCurrentNode(row, true);
}
</script>

Input ​

InputTypeRequired / defaultDescription
nodeNodeRequiredElement Plus Tree node instance.
shouldAutoExpandParentboolean | undefinedOptionalWhether to automatically expand the target's parents.

Returns ​

ValueTypeDescription
resultvoidNo return value.

getNode Node ​

Gets a Tree node by data or key.

Signature ​

ts
getNode(data: import("element-plus").TreeKey | TreeNodeData): import("element-plus/es/components/tree/src/model/node.mjs").default;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	const result = componentRef.value?.getNode(row);
	console.log(result);
}
</script>

Input ​

InputTypeRequired / defaultDescription
dataTreeNodeData | TreeKeyRequiredBusiness data to query, insert, remove, or replace.

Returns ​

ValueTypeDescription
resultNodeMethod result consistent with the current component state.

remove Remove ​

Removes a Tree node; requires node-key.

Signature ​

ts
remove(data: TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	componentRef.value?.remove(row);
}
</script>

Input ​

InputTypeRequired / defaultDescription
dataTreeNodeData | NodeRequiredBusiness data to query, insert, remove, or replace.

Returns ​

ValueTypeDescription
resultvoidNo return value.

append Append ​

Appends a child to a Tree node.

Signature ​

ts
append(data: TreeNodeData, parentNode: TreeNodeData | import("element-plus").TreeKey | import("element-plus/es/components/tree/src/model/node.mjs").default): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	componentRef.value?.append(row, row);
}
</script>

Input ​

InputTypeRequired / defaultDescription
dataTreeNodeDataRequiredBusiness data to query, insert, remove, or replace.
parentNodeTreeNodeData | TreeKey | NodeRequiredParent data, key, or node instance for insertion.

Returns ​

ValueTypeDescription
resultvoidNo return value.

insertBefore Insert ​

Inserts a node before the specified Tree node.

Signature ​

ts
insertBefore(data: TreeNodeData, refNode: import("element-plus").TreeKey | TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	componentRef.value?.insertBefore(row, row);
}
</script>

Input ​

InputTypeRequired / defaultDescription
dataTreeNodeDataRequiredBusiness data to query, insert, remove, or replace.
refNodeTreeNodeData | TreeKey | NodeRequiredReference node data, key, or instance for insertion.

Returns ​

ValueTypeDescription
resultvoidNo return value.

insertAfter Insert ​

Inserts a node after the specified Tree node.

Signature ​

ts
insertAfter(data: TreeNodeData, refNode: import("element-plus").TreeKey | TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default): void;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
const row = { id: 1, name: "Fast" };
function handleExample() {
	componentRef.value?.insertAfter(row, row);
}
</script>

Input ​

InputTypeRequired / defaultDescription
dataTreeNodeDataRequiredBusiness data to query, insert, remove, or replace.
refNodeTreeNodeData | TreeKey | NodeRequiredReference node data, key, or instance for insertion.

Returns ​

ValueTypeDescription
resultvoidNo return value.

refresh Refresh ​

Refreshes.

Signature ​

ts
refresh(): Promise<void>;

Example ​

vue
<template>
	<FaTree ref="componentRef" />
	<button type="button" @click="handleExample">Call method</button>
</template>

<script setup lang="ts">
import { ref } from "vue";
import { FaTree } from "fast-element-plus";

const componentRef = ref<InstanceType<typeof FaTree>>();
async function handleExample() {
	const result = await componentRef.value?.refresh();
	console.log(result);
}
</script>

Input ​

This method has no input parameters.

Returns ​

ValueTypeDescription
resultPromise<void>Asynchronous result; callers handle Promise rejection.