console
var Main = {
data() {
return {
tableData: [],
gridOptions: {
border: true,
formConfig: {
data: {
startTime: null,
endTime: null,
},
items: [{
title: "时间筛选",
itemRender: {
name: "VxeDateRangePicker",
startField: "startTime",
endField: "endTime",
props: {
type: "datetime",
valueFormat: "timestamp", // 绑定值为毫秒时间戳
labelFormat: "yyyy-MM-dd HH:mm:ss",
placeholder: "开始时间-结束时间"
}
}
}, {
itemRender: {
name: "VxeButtonGroup",
options: [
{ type: "submit", content: "搜索", status: "success" }
],
events: {
click(cellParams, params) {
const formData = cellParams.$grid.getFormData()
console.log(formData.startTime)
console.log(formData.endTime)
}
}
}
}]
},
columns: [
{ type: 'seq', width: 60 },
{ field: 'name', title: 'Name' },
{ field: 'sex', title: 'Sex' },
{ field: 'date', title: 'Date' },
{ field: 'address', title: 'Address' }
],
data: []
}
}
},
created() {
var list1 = []
var list2 = []
for (var index = 0; index < 3; index++) {
list1.push({
name: 'test' + index,
role: 'developer',
sex: 'Man',
date: '2019-05-01',
time: 1556677810888 + index * 500,
region: 'ShenZhen',
address: 'address abc' + index
})
list2.push({
name: 'test' + index,
role: 'developer',
sex: 'Man',
date: '2019-05-01',
time: 1556677810888 + index * 500,
region: 'ShenZhen',
address: '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.15.23"></script>
<script src="https://unpkg.com/vxe-table@4.19.17"></script>
<!-- 使用 cdn 引用方式需要注意是否锁定版本,默认指向最新版本 -->
<div id="app">
<div>
<p>Grid 演示</p>
<vxe-grid v-bind="gridOptions"></vxe-grid>
</div>
</div>
@import url("https://unpkg.com/vxe-pc-ui@4.15.23/lib/style.css");
@import url("https://unpkg.com/vxe-table@4.19.17/lib/style.css");