console
var Main = {
data() {
return {
tableData: [],
gridOptions: {
border: true,
height: 400,
columns: [
{ type: 'seq', width: 60, resizable: true, },
{ field: 'name', title: 'Name', width: 133, },
{ field: 'sex', title: 'Sex', width: 133 },
{ field: 'date', title: 'Date', width: 133 },
{ field: 'address', title: 'Address0', width: 133 },
{ field: 'address31', title: 'Address31', width: 133 },
{ field: 'address1', title: 'Address1', width: 133 },
{ field: 'address2', title: 'Address2', width: 133 },
{ field: 'address3', title: 'Address3', width: 133 },
{ field: 'address4', title: 'Address4', width: 133 },
{ field: 'address5', title: 'Address5', width: 133 },
{ field: 'address6', title: 'Address6', width: 133 },
{ field: 'address7', title: 'Address7', width: 133 },
{ field: 'address8', title: 'Address8', width: 133 },
{ field: 'address9', title: 'Address9', width: 133 },
{ field: 'address10', title: 'Address10', width: 133 },
{ field: 'address11', title: 'Address11', width: 133 },
{ field: 'address12', title: 'Address12', width: 133 },
{ field: 'address13', title: 'Address13', width: 133 },
{ field: 'address14', title: 'Address14', width: 133 },
{ field: 'address15', title: 'Address15', width: 133 },
{ field: 'address16', title: 'Address16', width: 133 },
{ field: 'address17', title: 'Address17', width: 133 },
{ field: 'address18', title: 'Address18', width: 133 },
{ field: 'address19', title: 'Address19', width: 133 },
{ field: 'address20', title: 'Address20', width: 133 },
{ field: 'address21', title: 'Address21', width: 133 }
],
data: [],
columnConfig: {
resizable: true, // 启用列宽拖拽调整宽度
drag: true, // 启用行拖拽调整顺序
useKey: true
},
toolbarConfig: {
custom: true // 工具栏启用自定义列按钮
},
// https://vxetable.cn/pluginDocs/table/#/extendCellArea/grid/scroll/vertical
scrollY: {
enabled: true, // 是否开启纵向虚拟滚动
gt: 0, // 指定大于指定行时自动启动纵向虚拟滚动,如果为 0 则总是启用
mode: 'wheel'
},
scrollX: {
enabled: true, // 是否开启纵向虚拟滚动
gt: 0, // 指定大于指定行时自动启动纵向虚拟滚动,如果为 0 则总是启用
mode: 'wheel'
},
}
}
},
created() {
var list1 = []
var list2 = []
for (var index = 0; index < 300; index++) {
list2.push({
name: 'test' + index,
role: 'developer',
sex: 'Man',
date: '2019-05-01',
time: 1556677810888 + index * 500,
region: 'ShenZhen',
address: 'address abc' + index,
address1: 'address abc' + index,
address2: 'address abc' + index,
address3: 'address abc' + index,
address4: 'address abc' + index,
address5: 'address abc' + index,
address6: 'address abc' + index,
address7: 'address abc' + index,
address8: 'address abc' + index,
address9: 'address abc' + index,
address10: 'address abc' + index,
address11: 'address abc' + index,
address12: 'address abc' + index,
address13: 'address abc' + index,
address14: 'address abc' + index,
address15: 'address abc' + index,
address16: 'address abc' + index,
address17: 'address abc' + index,
address18: 'address abc' + index,
address19: 'address abc' + index,
address20: 'address abc' + index
})
}
this.tableData = list1
this.gridOptions.data = list2
}
};
Vue.createApp(Main).use(VXETable).mount('#app')
<script src="https://unpkg.com/vue@3.5.13"></script>
<script src="https://unpkg.com/xe-utils"></script>
<script src="https://unpkg.com/vxe-pc-ui@4.3.36"></script>
<script src="https://unpkg.com/vxe-table@4.9.29"></script>
<div id="app">
<div>
<p>Table 演示</p>
<vxe-table
border
:data="tableData">
<vxe-column type="seq" width="60"></vxe-column>
<vxe-column field="name" title="Name"></vxe-column>
<vxe-column field="sex" title="Sex"></vxe-column>
<vxe-column field="date" title="Date"></vxe-column>
<vxe-column field="address" title="Address"></vxe-column>
</vxe-table>
<p>Grid 演示</p>
<vxe-grid v-bind="gridOptions"></vxe-grid>
</div>
</div>
@import url("https://unpkg.com/vxe-pc-ui@4.3.36/lib/style.css");
@import url("https://unpkg.com/vxe-table@4.9.29/lib/style.css");