1. 程式人生 > >iview的table實現全選

iview的table實現全選

1、html

<Table border height="500" :columns="columns" :data="dataSource"  :loading="loading" 
	    	@on-selection-change="selectRow" 
	    	></Table>

2、js

columns: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
			          {
			            title: '單位',
			            key: 'xxx',
			            algin: 'center',
			            width: 100
			          },
                ],

3、方法

getsxv(){
axios.get('/user')
  .then(function (res) {
    for (let i =0; i<res.length; i++) {
		res[i]._checked = true;
    }
  })
  .catch(function (error) {
    console.log(error);
  });
}