Vue动态生成表格的行和列如何实现

本篇内容主要讲解“Vue动态生成表格的行和列如何实现”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“Vue动态生成表格的行和列如何实现”吧!

具体的实现代码如下:

<template>
 <div class="boxShadow">
 <div >
 
 <el-table
 :data="tables"
 ref="multipleTable"
 tooltip-effect="dark"
 
 @selection-change='selectArInfo'>
 <el-table-column type="selection" width="45px"></el-table-column>
 <el-table-column label="序号" width="62px" type="index">
 </el-table-column>
 <template v-for='(col) in tableData'>
  <el-table-column
  sortable
  :show-overflow-tooltip="true"
  :prop="col.dataItem"
  :label="col.dataName"
  :key="col.dataItem"
  width="124px">
  </el-table-column>
 </template>
 <el-table-column label="操作" width="80" align="center">
  <template slot-scope="scope">
  <el-button size="mini" class="del-com" @click="delTabColOne()" ><i class="iconfont icon-shanchu"></i></el-button>
  </template>
 </el-table-column>
 </el-table>
 
 
 </div>
 </div>
 
</template>
<script>
 import '../../assets/css/commlist.css'
 import '../../assets/css/commscoped.sass'
 export default {
 data () {
 return {
 tables: [{
  xiaoxue: '福兰',
  chuzhong: '加芳',
  gaozhong: '蒲庙',
  daxue: '西安',
  yanjiusheng: '西安',
  shangban: '北京'
 }, {
  xiaoxue: '南坊',
  chuzhong: '礼泉',
  gaozhong: '礼泉',
  daxue: '西安',
  yanjiusheng: '西安',
  shangban: '南坊'
 }, {
  xiaoxue: '马山',
  chuzhong: '加芳',
  gaozhong: '蒲庙',
  daxue: '西安',
  yanjiusheng: '重庆',
  shangban: '北京'
 }],
 tableData: [{
  dataItem: 'xiaoxue',
  dataName: '小学'
 }, {
  dataItem: 'chuzhong',
  dataName: '初中'
 }, {
  dataItem: 'gaozhong',
  dataName: '高中'
 }, {
  dataItem: 'daxue',
  dataName: '大学'
 }, {
  dataItem: 'yanjiusheng',
  dataName: '研究生'
 }, {
  dataItem: 'shangban',
  dataName: '上班'
 }]
 }
 },
 methods: {
 // 获取表格选中时的数据
 selectArInfo (val) {
 this.selectArr = val
 }
 }
 }
</script>

Vue的优点

Vue具体轻量级框架、简单易学、双向数据绑定、组件化、数据和结构的分离、虚拟DOM、运行速度快等优势,Vue中页面使用的是局部刷新,不用每次跳转页面都要请求所有数据和dom,可以大大提升访问速度和用户体验。

到此,相信大家对“Vue动态生成表格的行和列如何实现”有了更深的了解,不妨来实际操作一番吧!这里是蜗牛博客网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:niceseo99@gmail.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

评论

有免费节点资源,我们会通知你!加入纸飞机订阅群

×
天气预报查看日历分享网页手机扫码留言评论电报频道链接