console
var Main = {
data() {
return {
ids:[],
tableData: []
}
},
methods:{
setSelection(){
this.ids = [1,2]
},
},
created () {
var list = []
for(var index = 0; index < 100; index++){
list.push({
id: index,
name: 'test' + index,
role: 'developer',
sex: 'Man',
date: '2019-05-01',
time: 1556677810888 + index * 500,
region: 'ShenZhen',
address: 'address abc' + index
})
}
this.tableData = list
}
};
var Ctor = Vue.extend(Main);
new Ctor().$mount('#app')
<script src="//unpkg.com/vue"></script>
<script src="//unpkg.com/xe-utils"></script>
<script src="//unpkg.com/vxe-table"></script>
<script src="https://cdn.bootcss.com/lodash.js/4.17.15/lodash.min.js"></script>
<div id="app">
<template>
<div>
<vxe-button @click="setSelection()"
>选中</vxe-button
>
{{ids}}
<vxe-table
ref="xTree"
border
row-id="id"
height="500"
:data="tableData"
:checkbox-config=" {
labelField: 'id',
checkRowKeys: ids,
}"
>
<vxe-table-column type="checkbox" width="100"></vxe-table-column>
<vxe-table-column field="id" title="Id"></vxe-table-column>
<vxe-table-column field="name" title="Name"></vxe-table-column>
<vxe-table-column field="sex" title="Sex"></vxe-table-column>
<vxe-table-column field="date" title="Date"></vxe-table-column>
<vxe-table-column field="address" title="Address"></vxe-table-column>
</vxe-table>
</div>
</template>
</div>
@import url("//unpkg.com/vxe-table/lib/index.css");