横向树状+竖向树状

   <el-table-column type="expand" prop="data" label="" width="40">
          <template slot-scope="scope">
            <!--   一级-->
            <div v-if="scope.row.children.length > 0">
              <el-row :class="['bt_border', idx1 === 0 ? 'tp_border' : '']"
                      v-for="(item1, idx1) in scope.row.children"
                      :key="item1.id"
              >
                <el-col :span="6">
                  <el-tag
                      @close="delrole(scope.row, item1.id)"
                      closable
                  >{{ item1.authName }}
                  </el-tag>
                </el-col>
                <el-col :span="18">
                  <!-- 二级权限 -->
                  <el-row v-for="item2 in item1.children" :key="item2.id">
                    <el-col :span="6">
                      <el-tag
                          @close="delrole(scope.row, item2.id)"
                          closable
                          type="success"
                      >{{ item2.authName }}
                      </el-tag
                      >
                      <i class="el-icon-caret-right"></i>
                    </el-col>
                    <el-col :span="18">
                      <el-tag
                          closable
                          type="warning"
                          v-for="item3 in item2.children"
                          :key="item3.id"
                          @close="delrole(scope.row, item3.id)"
                      >
                        {{ item3.authName }}
                      </el-tag>
                    </el-col>
                  </el-row>
                </el-col>
              </el-row>
            </div>
            <div v-else>该角色暂无权限</div>
          </template>
        </el-table-column>

↓↓↓↓↓↓↓↓
在这里插入图片描述

<el-dialog title="分配权限" :visible.sync="Trees" @close="resetTree">
      <el-tree
          :data="data"
          show-checkbox
          default-expand-all
          node-key="id"
          ref="path"
          :default-checked-keys="checkedKeysArr"
          :props="defaultProps"
      >
      </el-tree>
      <div slot="footer" class="dialog-footer">
        <el-button @click="Trees = false">取 消</el-button>
        <el-button type="primary" @click="setRightsToRole">确 定</el-button>
      </div>
    </el-dialog>

↓↓↓↓↓↓↓
在这里插入图片描述

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要使用SVG制作一个横向树形结构,可以按以下步骤进行: 1. 首先,使用Vue创建一个组件,命名为Tree。 2. 在Tree组件中,使用SVG标签来绘制树形结构。SVG是一种可缩放矢量图形格式,可以通过代码来描述图形,非常适合用来绘制图形化的数据结构。 3. 在SVG标签中,使用<g>标签来组合多个图形元素,形成一个组合。 4. 使用<path>标签来绘制树形结构中的线条。可以使用<path>标签的d属性来定义绘制路径,例如M x1 y1 L x2 y2表示从点(x1,y1)到点(x2,y2)绘制一条直线。 5. 使用<circle>标签来绘制树形结构中的节点。可以使用<circle>标签的cx和cy属性来定义圆心坐标,r属性来定义半径。 6. 在Tree组件中,使用props属性来接收传入的树形结构数据。可以使用递归的方式,将树形结构数据中的每个节点都绘制出来。 下面是一个简单的示例代码: ```html <template> <svg> <g> <path :d="line.path" stroke="black" fill="none" /> <circle :cx="node.x" :cy="node.y" :r="node.r" fill="red" /> <text :x="node.x" :y="node.y">{{ node.value }}</text> </g> <tree v-for="child in node.children" :node="child" :key="child.id" /> </svg> </template> <script> export default { name: "Tree", props: { node: { type: Object, required: true, }, }, computed: { line() { const { x, y, width, height } = this.node; const path = `M ${x} ${y + height / 2} H ${x + width}`; return { path }; }, }, components: { Tree, }, }; </script> ``` 在这个示例中,我们定义了一个Tree组件,接收一个node属性作为参数。每个Tree组件都会绘制一个节点和一条线条,然后递归地绘制子节点。在计算属性line中,我们使用节点的位置和尺寸信息来计算线条的路径。在模板中,我们使用<g>标签来组合多个图形元素,使用v-for指令来遍历子节点,并递归地渲染Tree组件。 当我们使用这个Tree组件时,可以将树形结构数据作为参数传入: ```html <template> <tree :node="treeData" /> </template> <script> import Tree from "./Tree.vue"; export default { name: "App", components: { Tree, }, data() { return { treeData: { id: 1, value: "root", children: [ { id: 2, value: "child 1", children: [ { id: 4, value: "grandchild 1", children: [], }, { id: 5, value: "grandchild 2", children: [], }, ], }, { id: 3, value: "child 2", children: [], }, ], }, }; }, }; </script> ``` 这样就可以在Vue中使用SVG绘制出一个横向树形结构了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值