发布于2023-02-19 12:40 阅读(1733) 评论(0) 点赞(16) 收藏(4)
提示:以下是本篇文章正文内容,下面案例可供参考
<vxe-grid v-bind="mixinGridOptions"></vxe-grid>
重点在于数据
data(){
return {
mixinGridOptions: {
stripe:true,
border: 'none',
resizable: false,
showOverflow: true,
align: 'center',
columns: [], // 这里自定义或者跟后端约定
data: [] // 这里赋值表格的数据
}
}
}
mixinGridOptions
被我放到mixins
里 只需要关注 columns
即可
代码实例
mixinGridOptions.columns
columns: [
{ field: 'operateTypeStr', title: '操作类型' },
{ field: 'userName', title: '操作人用户名' },
{ field: 'fullName', title: '操作人姓名' },
{ field: 'tenantCnName', title: '所在组织' },
{ field: 'ip', title: 'IP地址' },
{ field: 'action', title: '事件' }
]
{ type: 'seq', title: '序号', width: 70 }
{ type: 'checkbox', width: 50 }
ref=“xGrid”
@checkbox-change=“checkboxChangeEvent”
@checkbox-all=“checkboxChangeEvent”
<vxe-grid ref="xGrid" v-bind="mixinGridOptions" @checkbox-change="checkboxChangeEvent"
@checkbox-all="checkboxChangeEvent">
// xGrid 全选
checkboxChangeEvent () {
const $grid = this.$refs.xGrid;
this.isAllChecked = $grid.isAllCheckboxChecked(); // 用于 type=checkbox,判断列头复选框是否被选中
this.isIndeterminate = $grid.isAllCheckboxIndeterminate(); // 用于 type=checkbox,判断复选行数据是否半选
this.multipleTable = $grid.getCheckboxRecords();
}
// 选中手动清空
clearCheckboxRow(name){
typeof name === 'undefined' ? name = 'table' : name;
const records = this.$refs[name].clearCheckboxRow(); // 用于 type=checkbox,手动清空用户的选择
this.multipleTable = records;
}
{
field: 'operateTime', title: '操作时间',
formatter: ({ cellValue }) => {
return cellValue ? moment(cellValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
以前是 :underline="false"
现在是 underline={false}
{
field: 'fullName', title: '姓名',
slots: {
default: ({ row }) => {
if (this.readOnly) {
return <el-link underline={false} type="primary" onClick={() => this.moduleDialog(row)}>{row.fullName}</el-link>
} else {
return row.fullName
}
}
}
},
{
title: '操作',
slots: {
default: 'operationButtons',
}
}
<vxe-grid ref="xGrid" v-bind="mixinGridOptions">
<template #operationButtons="{ row }">
<span>编辑</span>
</template>
</vxe-grid>
作者:前端霸主
链接:http://www.qianduanheidong.com/blog/article/498327/160a920f57e4ada32000/
来源:前端黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 前端黑洞网 All Rights Reserved 版权所有,并保留所有权利。 京ICP备18063182号-3
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!