vue树组件循环表格

最近做项目需要实现循环表格这个需求,其中实用到了循环组件,特此记录一下,这是需要实现的功能,如下图:
在这里插入图片描述

vue中实现组件循环

父组件

<template>
	<div>
		<ul>
			<li v-for="(item,index) in asideList" ::key = "index" >
				<p class="main-title">
					<span class="title">{{item.title}}</span>
					<span class="iconfont icon-arrow-right-1"></span>
				</p>
				<ul v-if="item.children" >
					<AsideItem :asideChildren="item.children" ></AsideItem>
				</ul>
			</li>
		</ul>
	</div>
</template>

循环组件


<template>
	<div>
		<li v-for="(item,index) in asideChildren" v-bind:key="index" >
			<p class="secondary-title" @click.prevent="secondaryDropDown" >
				<span>{{item.title}}</span>
			</p>
			<ul v-if="item.children">
				<AsideItem :asideChildren="item.children"></AsideItem>
			</ul>			
		</li>
	</div>
</template>
 
<script>
	export default{
		name: 'AsideItem',
		props: {
			asideChildren: {
				type: Array
			}
		},
	}
</script>

表格实现

父组件:

<template>
  <div>
    <div class="title"><span>信息统计:已提交1{{  }}条,未提交:1{{  }}条,置回1{{ }}条,统计时间:1{{  }}</span></div>
    <div class="table_box border_righttopleft">
      <!-- thead -->
      <div class="head_box">
        <div class="head_title head_1 border_bottomright content">类别权重</div>
        <div class="head_title head_2 border_bottomright">序号</div>
        <div class="head_title head_3 border_bottomright">指标权重</div>
        <div class="head_title head_4 border_bottomright">评分内容</div>
        <div class="head_title head_6 border_bottomright">提示内容</div>
        <div class="head_title head_7 border_bottomright">信息录入</div>
      </div>
      <div class="tableBody" v-for="(item,index) in dataInfo" :key="index">
        <div class="clow">
          <!-- 类别权重 -->
          <div class="clow1" :style="{ height:item.total*40 + 'px' }">{{ item.name }}</div>
          <!-- 序号 -->
          <div class="clow2">
            <div v-for="(item2,index2) in item.children" :style="{ height: item2.lengths*40 + 'px' }">
              <div class="clow2Bottom" :style="{height:item2.length*40+'px'}">{{ index2+1 }}</div>
            </div>
          </div>
          <!-- 指标权重 -->
          <div class="clow3">
            <div v-for="(item2,index2) in item.children">
              <div style="float: left;" class="clow3Top" :style="{height:item2.length*40+'px'}">
                {{ item2.name }}
              </div>
              <!-- 树最近组件 -->
              <div v-if="item2.children" style="float: left;width: 1018px;">
                <AsideItem :asideChildren="item2.children"></AsideItem>
              </div>
            </div>
          </div>

        </div>

      </div>
    </div>
  </div>
</template>
<script>
import AsideItem from "./tree.vue";
export default {
  name: "environmentEntry",
  components: { ceshi, AsideItem },
  data() {
    return {
      Tabheight: 440,
      total: 14,
      dataInfo: [
        {
          id: "1",
          name: "单位环境管理信息20分",
          total: 14,
          children: [
            {
              id: "2",
              name: "环保责任制3分",
              length: 7,
              // 数据看这
              children: [
                {
                  id: "31",
                  name: "1-1",
                  length: 4,
                  children: [
                    {
                      id: "41",
                      name: "21",
                      length: 2,
                      children: [
                        {
                          id: "51",
                          name: "最后一层",
                        },
                        {
                          id: "52",
                          name: "大花脸",
                        },
                      ],
                    },
                    {
                      id: "41",
                      name: "地二层",
                    },
                    {
                      id: "41",
                      name: "第二程2层",
                    },
                  ],
                },
                { id: "32", name: "1-2" },
                { id: "33", name: "1-3" },
                { id: "34", name: "1-4" },
              ],
            },
            {
              id: "3",
              name: " 2分",
              length: 2,
              children: [
                { id: "35", name: "2" },
                {
                  id: "36",
                  name: "2",
                },
              ],
            },
            {
              id: "4",
              name: "3",
              length: 3,
              children: [
                { id: "37", name: "3" },
                { id: "38", name: "3" },
                { id: "39", name: "3" },
              ],
            },
            {
              id: "5",
              name: "4",
              length: 2,
              children: [
                { id: "40", name: "4" },
                { id: "41", name: "4" },
              ],
            },
          ],
        },
        {
          id: "6",
          name: "环保行政管理信息75分",
          total: 8,
          // 最后一层所有的条数
          children: [
            {
              id: "7",
              name: "环保行政许可管理25分",
              length: 8,
              children: [
                {
                  id: "8",
                  name: "建设项目环境影响评价文件审批",
                  length: 2,
                  children: [
                    { id: "9", name: "登记表类项目未依法备案" },
                    {
                      id: "11",
                      name: "报告书类项目(未依法报批、未重新报批、未报请重新审核,未经批准、未经原审批部门重新审核)",
                    },
                  ],
                },
                {
                  id: "12",
                  name: "排污许可证管理",
                  length: 1,
                  children: [{ name: "实行排污许可重点管理的企业事业单位" }],
                },
                {
                  id: "13",
                  name: "危险废物经营许可证管理",
                  length: 1,
                  children: [
                    {
                      name: "实行排污许可重点管理的企业事业单位",
                      id: "56",
                      length: 1,
                      children: [{ name: "hihuihuihuihiuh" }],
                    },
                  ],
                },
                { id: "14", name: "危险废物转移审批" },
                { id: "15", name: "危险废物转移审批23" },
                { id: "16", name: "危险废物转移审批45" },
                { id: "17", name: "危险废物转移审批45" },
              ],
            },
          ],
        },
      ],
    };
  },
  mounted() {},
  watch: {},
  created() {},
  methods: {
    tips(data) {
      console.log(1111111);
      console.log(data, "pppp");
    },
    manage(data) {
      console.log(data, "pppp");
    },
  },
};
</script>
<style lang="less" scoped>
.title {
  text-align: center;
  font-size: 16px;
}
.table_box {
  width: 1361px;
  margin: 0 auto;
}
.tableBody {
  // border-bottom: 1px solid #888888;
  border-right: 1px solid #888888;
}
.border_righttopleft {
  border-top: 1px solid #888888;
  border-left: 1px solid #888888;
}
.clow {
  display: flex;
  text-align: center;
  align-items: center;
  // div{border:1px solid #888888;}
}
.clow1 {
  width: 141px;
  border-right: 1px solid #888888;
  border-bottom: 1px solid #888888;
}
.clow2 {
  width: 60px;
  border-right: 1px solid #888888;
}
.clow2Bottom {
  border-bottom: 1px solid #888888;
}
.clow3 {
  width: 1160px;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
}
.clow4 {
  width: 900px;
}
.clow5 {
  width: 60px;
}
.clow6 {
  width: 60px;
}
.clow3Top {
  width: 140px;
  border-right: 1px solid #888888;
  border-bottom: 1px solid #888888;
}
.clow3Top:last-child {
  // border-bottom: none;
}
.content {
  border-right: 1px, solid #888888;
  border-bottom: 1px solid #888888;
}
.content:last-child {
  // border-bottom:none;
}
.button {
  border-left: 1px, solid #888888;
}
.border_bottomright {
  border-bottom: 1px solid #888888;
  border-right: 1px solid #888888;
}

.border_bottom {
  border-bottom: 1px solid #888888;
}

.border_bottomleft {
  border-bottom: 1px solid #888888;
  border-left: 1px solid #888888;
  border-right: 1px solid #888888;
}

/* 头部样式 */
.head_box {
  display: flex;
}

.head_title {
  font-size: 12px;
  text-align: center;
}

.border_bottomleft {
  font-size: 12px;
}

.head_1 {
  width: 140px;
  height: 30px;
  line-height: 30px;
}

.head_2 {
  width: 60px;
  height: 30px;
  line-height: 30px;
  text-align: center;
}

.head_3 {
  width: 140px;
  height: 30px;
  line-height: 30px;
}

.head_4 {
  width: 900px;
  height: 30px;
  line-height: 30px;
}

/*  .head_5 {
	width: 170px;
	height: 30px;
	line-height: 30px;
}  */
.head_6 {
  width: 60px;
  height: 30px;
  line-height: 30px;
}

.head_7 {
  width: 60px;
  height: 30px;
  line-height: 30px;
}

/*  .body_5 {
	width:170px;
} */
.body_6 {
  width: 60px;
}

.body_1 {
  width: 140px;
}
.secondText {
  border-bottom: 1px solid #888888;
  border-right: 1px solid #888888;
}
.thirdText {
  border-bottom: 1px solid #888888;
}
</style>

子组件

<template>
  <div class="clowTable">
    <div class="clotableList" v-if="asideChildren" v-for="(item,index) in asideChildren" v-bind:key="index">
      <div v-if="item.children" class="content" :style="{height:item.length*40+'px',with:900-(item.ceng)*200+'px'}">
        <div class="secondary-title" style="text-align: left;width: 200px;" :style="{height:item.length*40+'px'}">
          {{item.name}}
        </div>
        <div>
          <AsideItem :asideChildren="item.children"></AsideItem>
        </div>
      </div>
      <!-- 无子集 -->
      <!-- 层数 -->
      <div v-if="!item.children" class="content" style="height: 40px;" :style="{with:1018-(item.ceng)*200+'px'}">
        <div style="float: left;"> {{ item.name }}</div>
        <div style="float: right;width: 120px;display: flex;height: 40px;">
          <div class="button" style="width: 58px;border-left: 1px solid #888888;"><Button type="primary" size="small"
              @click="tips(item)">提示</Button></div>
          <div class="button" style="width: 58px; border-left: 1px solid #888888;"><Button type="primary" size="small"
              @click="manage(item)">管理</Button></div>
        </div>
      </div>
    </div>
  </div>
</template>
 
<script>
export default {
  name: "AsideItem",
  props: {
    asideChildren: {
      type: Array,
    },
  },
  methods:{
    tips(data) {
      console.log(1111111);
      console.log(data, "pppp");
    },
    manage(data) {
      console.log(data, "pppp");
    },
  }
};
</script>
<style scoped>
.clowTable {
}
.content {
  border-bottom: 1px solid #88888888;
}
.secondary-title {
  border-right: 1px solid #888888;
  float: left;
}
</style>


最终实现功能。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/39427.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

【HCIA】10.VLAN间通信

VLAN间通信的解决方法 使用路由器的物理接口 路由器三层接口作为网关&#xff0c;转发本网段前往其它网段的流量。路由器三层接口无法处理携带VLAN Tag的数据帧&#xff0c;因此交换机上联路由器的接口需配置为Access。路由器的一个物理接口作为一个VLAN的网关&#xff0c;因此…

2023-07-14:讲一讲Kafka与RocketMQ中存储设计的异同?

2023-07-14&#xff1a;讲一讲Kafka与RocketMQ中存储设计的异同&#xff1f; 答案2023-07-14&#xff1a; 在Kafka中&#xff0c;文件的布局采用了Topic/Partition的方式&#xff0c;每个分区对应一个物理文件夹&#xff0c;且在分区文件级别上实现了顺序写入。然而&#xff0…

Qt Creator常用快捷键及技巧

文章目录 1.[Qt Creator常用快捷键及技巧提升编码效率]2.win10上安装QT &#xff0c;选择安装组件3.qt配置过程中主要注意的几点4.目录结构附&#xff1a;网友整理快捷方式&#xff1a; 1.[Qt Creator常用快捷键及技巧提升编码效率] (https://blog.csdn.net/luoyayun361/artic…

nginx+lua+redis环境搭建(文末赋上脚本)

目录 需求背景 环境搭建后nginx和redis版本 系统环境 搭建步骤 配置服务器DNS 安装ntpdate同步一下系统时间 安装网络工具、编译工具及依赖库 创建软件包下载目录、nginx和redis安装目录 下载配置安装lua解释器LuaJIT 下载nginx NDK&#xff08;ngx_devel_kit&#xff09…

三菱q以太网简单cpu通讯

产品概述 捷米特JM-ETH-QnA是一款经济型的以太网通讯处理器&#xff0c;是为满足日益增多的工厂设备信息化需求&#xff08;设备网络监控和生产管理&#xff09;而设计&#xff0c;用于三菱Q2A/Q2AS1/Q3A/Q4A等多个QnA系列PLC的以太网数据采集&#xff0c;非常方便构建生产管理…

前端uni-app自定义精美全端复制文本插件,支持全端文本复制插件 可设置复制按钮颜色

随着技术的发展&#xff0c;开发的复杂度也越来越高&#xff0c;传统开发方式将一个系统做成了整块应用&#xff0c;经常出现的情况就是一个小小的改动或者一个小功能的增加可能会引起整体逻辑的修改&#xff0c;造成牵一发而动全身。 通过组件化开发&#xff0c;可以有效实现…

Qt的三大优势,打造高效工业软件开发:

强大的跨平台特性&#xff1a;Qt拥有优良的跨平台支持&#xff0c;可以在众多操作系统上运行&#xff0c;包括Microsoft Windows、Linux、Solaris、HP-UX、FreeBSD、QNX等等。这使得开发者可以轻松地将应用程序部署到不同的平台上&#xff0c;提高开发效率和覆盖范围。 面向对…

“体验家”亮相第六届IAIC成都国际医美产业大会

6月23日-25日&#xff0c;第六届IAIC成都国际医美产业大会暨“医美之都”高峰会议在成都世纪城国际会议中心成功举行。本次大会邀请了来自国家药品监督管理局、部分省市地区的相关领导莅临指导&#xff0c;以及来自全国100医美行业头部平台&#xff0c;近2000位医美产业领军代表…

什么是统一建模语言(UML)UML与UML类图的基本概念

什么是统一建模语言UML&#xff08;Unified Modeling Language&#xff09; UML&#xff08;统一建模语言&#xff09;是一种通用的建模语言&#xff0c;用于描述软件系统的结构、行为和交互。它提供了一组符号和规则&#xff0c;用于创建可视化的图形模型&#xff0c;帮助开发…

ios 启动页storyboard 使用记录

本文简单记录ios启动页storyboard 如何使用和注意事项。 xcode窗口简介 以xcode14为例&#xff0c;新建项目如下图&#xff0c;左边文件栏中的LaunchScreen.storyboard 为默认启动页布局。窗口中间部分是storyboard中的组件列表&#xff0c;右侧为预览&#xff0c;可以看到渲…

Android 自定义CheckBox样式,设置切换背景图,类似于RadioButton

文章目录 概要自定义CheckBoX资源文件如下使用方法实现效果 概要 目前要实现类似于Radiobutton选择按钮&#xff0c;如果只有一个RadioButton&#xff0c;就不能和radio Group连用&#xff0c;导致选择没办法取消&#xff0c;如果要实现只能代码中进行操作&#xff0c;过于繁琐…

ASEMI快恢复二极管MUR20100CTR在电子工程中的应用

编辑-Z 随着电子技术的日益发展&#xff0c;各种电子元件的使用场景与需求也在逐步扩大。今天&#xff0c;我们将聚焦于一款广泛应用于各类电路的二极管——MUR20100CTR&#xff0c;来详细解读其性能特征及应用。 一、MUR20100CTR二极管的主要特性 MUR20100CTR是一款极高性能的…

HTML语法

文章目录 前言HTML 文件基本结构常见标签标签种类特殊符号图片链接a链接 双标签链接 列表表格 &#xff1a;表单多行文本域: 前言 HTML是有标签组成的 <body>hello</body>大部分标签成对出现. 为开始标签, 为结束标签. 少数标签只有开始标签, 称为 “单标签”. 开…

Ubuntu 安装 Docker

本文目录 1. 卸载旧版本 Docker2. 更新及安装工具软件2.1 更新软件包列表2.2 安装几个工具软件2.3 增加一个 docker 的官方 GPG key2.4 下载仓库文件 3. 安装 Docker3.1 再次更新系统3.2 安装 docker-ce 软件 4. 查看是否启动 Docker5. 验证是否安装成功 1. 卸载旧版本 Docker …

JS逆向系列之猿人学爬虫第18题-jsvmp - 洞察先机

文章目录 目标网址加密参数分析Python 实现往期逆向文章推荐目标网址 https://match.yuanrenxue.cn/match/18题目标着难度是困难级别,主要还是vmp保护的JS代码调试困难,理清逻辑就会变得简单了 加密参数分析 请求第一页时没有加密参数,从第二页开始,url会携带t和v两个参数…

文献阅读:MathPrompter: Mathematical Reasoning using Large Language Models

文献阅读&#xff1a;MathPrompter: Mathematical Reasoning using Large Language Models 1. 内容简介2. 方法细节3. 实验内容4. 结论&思考 文献链接&#xff1a;https://arxiv.org/abs/2303.05398 1. 内容简介 这篇文章是今年3月份的时候微软提出的一篇工作&#xff0…

TortoiseGit 入门指南07:创建分支

Git 的 分支 出了名的好用。其它的版本控制系统也提供分支&#xff0c;但在易用度上&#xff0c;只有两类版本控制系统&#xff1a;一种是 Git&#xff0c;一种是其它。 Bob 大叔在《匠艺整洁之道》中写道&#xff1a; 我曾经坚持拒绝分支。在使用 CVS 和 Subversion 的时候&a…

IDE /字符串 /字符编码与文本文件(如cpp源代码文件)

文章目录 概述文本编辑器如何识别文件的编码格式优先推测使用了UTF-8编码&#xff1f;字符编码的BOM字节序标记重分析各文本编辑器下的测试效果Qt Creator的文本编辑器系统记事本VS的文本编辑器Notepad 编译器与代码文件的字符编码ANSI编码其他 概述 前期在整理 《IDE/VS项目属…

备战秋招 | 笔试强训9

目录 一、选择题 二、编程题 三、选择题题解 四、编程题题解 一、选择题 1、某函数申明如下&#xff08;&#xff09; void Func(int &nVal1); A. Func(a) B. Func(&a) C. Func(*a) D. Func(&(*a)) 2、C语言中&#xff0c;类ClassA的构造函数和析构函数的执行…

如何生成一个漂亮的allure测试报告

前言 今天给大伙展示一下如何生成一个漂亮的allure测试报告&#xff0c;同时呢希望能帮助到大家。 定制化后的allure测试报告效果展示 如何定制化输出锦上添花的allure测试报告 使用前&#xff0c;先导入allure模块。 import allure 使用前&#xff0c;先熟悉运行测试用例…
最新文章