console
var Main = {
data() {
return {
gridOptions: {
border: true,
columns: [
{ type: 'seq', width: 60 },
{ field: 'name', title: 'Name' },
{ field: 'sex', title: 'Sex' },
{ field: 'date', title: 'Date' },
{ field: 'address', title: 'Address' }
],
data: [],
menuConfig: {
body: {
options: [[{ code: `right`, name: `右键菜单` }]],
},
},
},
events: {
menuClick({ menu, row }) {
switch (menu.code) {
case `right`: {
alert(`你成功触发了右键菜单`);
}
}
},
}
}
},
mounted() {
var list2 = []
for (var index = 0; index < 3; 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.gridOptions.data = list2
}
};
Vue.createApp(Main).use(VXETable).mount('#app')
<script src="https://cdn.jsdelivr.net/npm/vue@next"></script>
<script src="https://cdn.jsdelivr.net/npm/xe-utils"></script>
<script src="https://cdn.jsdelivr.net/npm/vxe-table@next"></script>
<div id="app">
<div>
<p>Grid 演示</p>
<vxe-grid v-bind="gridOptions" v-on="events"></vxe-grid>
</div>
</div>
@import url("https://cdn.jsdelivr.net/npm/vxe-table@next/lib/style.css");