首页 VueJS Vue 3.0+ElementUI Plus之EL-Tree不用TS获取所有选中的节点

Vue 3.0+ElementUI Plus之EL-Tree不用TS获取所有选中的节点

作者:胡同里的砖头 围观群众:144 更新于:2024-04-22

<template>
<el-tree
:data="treeData"
show-checkbox
node-key="id"
ref="treeRef"
></el-tree>
<el-button @click="getChecked">获取选中节点</el-button>
</template>

<script>

export default {
setup() {
const treeRef = ref(null);
const treeData = ref([{
id: 1,
label: '一级 1',
children: [{
id: 4,
label: '二级 1-1'
}]
}]);

const getChecked = () => {
if (treeRef.value) {
const checkedKeys = treeRef.value.getCheckedKeys();
console.log(checkedKeys);
}
};

return {
treeData,
treeRef,
getChecked
};
}
};
</script>

  • 本文标题: Vue 3.0+ElementUI Plus之EL-Tree不用TS获取所有选中的节点
  • 文章分类:【VueJS】
  • 非特殊说明,本文版权归【胡同里的砖头】个人博客 所有,转载请注明出处.
留言评论
站点声明:
1、本站【胡同里的砖头】个人博客,借鉴网上一些博客模板,取其各优点模块自行拼装开发,本博客开发纯属个人爱好。
2、所有笔记提供给广大用户交流使用,可转载,可复制,纯个人开发所遇问题锦集记录使用
Copyright © huzlblog.com All Rights Reserved. 备案号:苏ICP备2021056683号-8