当前位置: 首页 > news >正文

Vue,列表展示。多个字段拼接展示

在这里插入图片描述
如图展示,展示出一个字段是全部列表字段的全部信息

代码如下
data(){
		return { 
			listArr: [], 
		}
	}		
	created() {// 创建之前的钩子函数
	    this.getTab() // 执行加载获取tab列表的方法
	 },
 methods: {
	    getTab() {
	      getList().then(res => {// 去街口数据,
	        this.namelists = res.data.items, 假设数据返回有值 
	        let obj = {}
	        let str = '' // 重新赋值namelists
	        for (let i = 0; i < this.namelists.length; i++) {
	        // 要展示的字段拼接
	          str =
	            this.namelists[i].author +
	            '_' +
	            this.namelists[i].display_time +
	            '_' +
	            this.namelists[i].id +
	            '_' +
	            this.namelists[i].pageviews +
	            '_' +
	            this.namelists[i].status +
	            '_' +
	            this.namelists[i].title
           obj = {
	          name: str
	        }
	       this.namelists
	       this.namelists[i].name = str
	       this.listArr.push(this.namelists[i])
        }
     })
   },
}

另一种

<template>
  <div class="app-container">
    <button @click="_addd">annou </button>
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="ID" width="95">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="名称" prop="name" width="95" />
      <el-table-column label="Title">
        <template slot-scope="scope">
          {{ scope.row.title }}
        </template>
      </el-table-column>
      <el-table-column label="Author" width="110" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.author }}</span>
        </template>
      </el-table-column>
      <el-table-column label="Pageviews" width="110" align="center">
        <template slot-scope="scope">
          {{ scope.row.pageviews }}
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="Status" width="110" align="center">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="created_at" label="Display_time" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.display_time }}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getList } from '@/api/table'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        published: 'success',
        draft: 'gray',
        deleted: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: [],
      listLoading: true,
      id: 1
    }
  },
  mounted() { 挂载完成后执行这个方法
    this.fetchData() //
  },
  methods: {
    _addd() {
      this.$router.push({
        name: 'Test',
        params: {
          id: '111'
        }
      })
    },
    fetchData() {
      this.listLoading = true
      getList().then(response => {
        // console.log(response, '/')
        this.listArr = response.data.items
        let obj = {}
        let str = ''
        // const obj1 = {}
        for (let i = 0; i < this.listArr.length; i++) {
          str = this.listArr[i].author + '_' + this.listArr[i].display_time + '_' + this.listArr[i].pageviews
          // console.log(str, 'str')
          obj = {
            name: str
          }
          this.listArr[i].name = str
          this.list.push(this.listArr[i])
          // obj1 = {
          //   ...obj,
          //   ...this.listArr[i]
          // }
          // this.list.push(obj1)
        }
        this.listLoading = false
      })
    }
  }
}
</script>

相关文章:

  • Swift开发:NSLayoutConstraint纯代码实现自动布局-初级篇
  • react中的 Modal.confirm
  • 数据挖掘之决策树ID3算法(C#实现)
  • 【一小时入门】webpack 入门指南
  • Vue中 beforeRouteLeave离开路由之前要执行的操作
  • AF3.1.0简单二次封装
  • Vue 项目中 根目录中router路由拦截 beforeEach 常用的写法
  • 不同按钮模板自定义
  • react项目中没有路由守卫,需要拦截的话,只能在路径上拦截,可以自己去封装 Route
  • 跟锦数学160823-190322, 共 942 题
  • JavaScript新鲜事·第5期
  • vue 项目实战 递归
  • react 项目 tab列表 把返回的一个字段数组,全部 展示在一个字段里
  • Python语言学习 (六)1.2
  • js语法中 ?. 和 ?? 的含义以及用法说明
  • 「前端早读君006」移动开发必备:那些玩转H5的小技巧
  • Centos6.8 使用rpm安装mysql5.7
  • HTTP那些事
  • Invalidate和postInvalidate的区别
  • mockjs让前端开发独立于后端
  • Object.assign方法不能实现深复制
  • Redash本地开发环境搭建
  • Vue--数据传输
  • 阿里云应用高可用服务公测发布
  • 翻译:Hystrix - How To Use
  • 爬虫模拟登陆 SegmentFault
  • 普通函数和构造函数的区别
  • 深入体验bash on windows,在windows上搭建原生的linux开发环境,酷!
  • 项目管理碎碎念系列之一:干系人管理
  • C# - 为值类型重定义相等性
  • 不要一棍子打翻所有黑盒模型,其实可以让它们发挥作用 ...
  • ​Linux Ubuntu环境下使用docker构建spark运行环境(超级详细)
  • $con= MySQL有关填空题_2015年计算机二级考试《MySQL》提高练习题(10)
  • (env: Windows,mp,1.06.2308310; lib: 3.2.4) uniapp微信小程序
  • (iPhone/iPad开发)在UIWebView中自定义菜单栏
  • (pytorch进阶之路)扩散概率模型
  • (离散数学)逻辑连接词
  • (力扣)循环队列的实现与详解(C语言)
  • (强烈推荐)移动端音视频从零到上手(上)
  • (十五)Flask覆写wsgi_app函数实现自定义中间件
  • (幽默漫画)有个程序员老公,是怎样的体验?
  • (自适应手机端)响应式新闻博客知识类pbootcms网站模板 自媒体运营博客网站源码下载
  • .bat批处理(十一):替换字符串中包含百分号%的子串
  • .NET 5.0正式发布,有什么功能特性(翻译)
  • .NET CLR Hosting 简介
  • .NET Standard / dotnet-core / net472 —— .NET 究竟应该如何大小写?
  • .net 桌面开发 运行一阵子就自动关闭_聊城旋转门家用价格大约是多少,全自动旋转门,期待合作...
  • .NET/C# 编译期能确定的字符串会在字符串暂存池中不会被 GC 垃圾回收掉
  • .net快速开发框架源码分享
  • @synthesize和@dynamic分别有什么作用?
  • [AIGC] MySQL存储引擎详解
  • [BT]BUUCTF刷题第9天(3.27)
  • [BZOJ3223]文艺平衡树
  • [C#] 我的log4net使用手册
  • [CISCN 2019华东南]Web11