VUE-Element组件(四)tree

本文介绍了Vue中Element UI的Tree组件的使用方法,包括如何获取点击的节点信息、实现可选择的树并处理默认选中状态,以及解决父子节点强制关联的问题,通过设置check-strictly属性和后端数据处理来优化选中状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、点击tree,获取点击的item:

<template>
  <div class="container">
    <el-card>
      <table>
        <tr class="thclass">
          <th class="menuselect">
            <span style="float:left">菜单</span>
            <i style="float:right" class="el-icon-caret-bottom" />
          </th>
          <th>
            <el-button type="primary" size="mini">新增</el-button>
          </th>
        </tr>
        <tr class="maintr">
          <td class="linetd">
            <el-tree
              class="treecss"
              :data="menus"
              :props="defaultProps"
              node-key="id"
              @node-click="handleNodeClick"
            ></el-tree>
          </td>
          <td>
            当前选择的是{
  {currmenu.label}},id为{
  {currmenu.id}}
            <el-table :data="tableData" style="width: 100%">
              <el-table-column prop="date" label="日期" width="180"></el-table-column>
              <el-table-column prop="name" label="姓名" width="180"></el-table-column>
              <el-table-column prop="address" label="地址"></el-table-column>
            </el-table>
          </td>
        </tr>
      </table>
    </el-card>
  </div>
</template>

<script>
export default {
  data() {
    return {
      currmenu: "",
      menus: [
        {
          id: -1,
          label: "全部",
          children: [
            {
              id: 1,
              label: "小学",
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

w_t_y_y

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值