vue移动端使用table效果(超过左右拖拽滑动)

本文介绍了一款适用于移动端的表格插件,支持内容过多时的左右拖拽滑动功能。通过引入vue-easytable库并配置相应的样式和数据,实现了包括姓名、手机号码、爱好和地址等字段的表格展示,且支持单元格编辑和排序功能。代码示例展示了如何在Vue项目中使用该组件。

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

前言:

      一款很使用的移动端的table插件,内容太多左右拖拽滑动

官网入口:进入

实现效果:

 

实现代码:

<template>
  <div>
    <v-table
      is-horizontal-resize
      style="width:100%"
      :columns="columns"
      :table-data="tableData"
      row-hover-color="#eee"
      row-click-color="#edf7ff"
      :cell-edit-done="cellEditDone"
      @sort-change="sortChange"
      :paging-index="(pageIndex-1)*pageSize"
    ></v-table>
    <div class="mt20 mb20 bold" style="margin-top:10px;"></div>

  </div>
</template>

<script>
import 'vue-easytable/libs/themes-base/index.css'			// 引入样式
import {VTable, VPagination} from 'vue-easytable'
export default {
  props: [],
  watch: {},
  data() {
    return {
      tableData: [{
        "name": "赵伟",
        "tel": "156*****1987",
        "hobby": "钢琴、书法、唱歌",
        "address": "上海市黄浦区金陵东路569号17楼"
      },
      {
        "name": "李伟",
        "tel": "182*****1538",
        "hobby": "钢琴、书法、唱歌",
        "address": "上海市奉贤区南桥镇立新路12号2楼"
      },
      {
        "name": "孙伟",
        "tel": "161*****0097",
        "hobby": "钢琴、书法、唱歌",
        "address": "上海市崇明县城桥镇八一路739号"
      },
      {
        "name": "周伟",
        "tel": "197*****1123",
        "hobby": "钢琴、书法、唱歌",
        "address": "上海市青浦区青浦镇章浜路24号"
      },
      {
        "name": "吴伟",
        "tel": "183*****6678",
        "hobby": "钢琴、书法、唱歌",
        "address": "上海市松江区乐都西路867-871号"
      }
      ],
      columns: [{
        field: 'name',
        title: '姓名',
        width: 80,
        titleAlign: 'center',
        columnAlign: 'center',
        isEdit: true,
        formatter: function(rowData, rowIndex, pagingIndex, field) {
          return `<span class='cell-edit-color'>${rowData[field]}</span>`;
        },
        isResize: true,
        isFrozen: true
      },
      {
        field: 'tel',
        title: '手机号码',
        width: 150,
        titleAlign: 'center',
        columnAlign: 'center',
        isEdit: true,
        isResize: true
      },
      {
        field: 'hobby',
        title: '爱好',
        width: 150,
        titleAlign: 'center',
        columnAlign: 'center',
        isEdit: true,
        isResize: true
      },
      {
        field: 'address',
        title: '地址',
        width: 280,
        titleAlign: 'center',
        columnAlign: 'left',
        isEdit: true,
        formatter: function(rowData, rowIndex, pagingIndex, field) {
          console.log(rowData)
          console.log(field)
          return `<span class='cell-edit-color' style="color:red">${rowData[field]}</span>`;
        },
        isResize: true
      }
      ]
    }
  },
  created() {
  },
  mounted() {
  },
  methods: {},
  components: {},
  beforeDestroy() {
  }

}
</script>

<style lang='' scoped>

</style>

 

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

浩星

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

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

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

打赏作者

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

抵扣说明:

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

余额充值