console
new Vue({
el: '#app',
data() {
return {
tableData: [{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄'
}, {
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄'
}, {
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄'
}],
sortData: { prop: 'date', order: 'descending' }
}
},
mounted() {
const r = Number(1/0) || 0
console.log(r)
},
methods: {
formatter(row, column) {
return row.address;
},
sortChange(val) {
const { order } = val
console.log(order)
},
getArray () {
}
}
})
<div id="app">
<template>
<el-table :data="tableData" style="width: 100%" :default-sort="{prop: 'date', order: 'descending'}" @sort-change="sortChange">
<el-table-column prop="date" label="日期" :sortable="'custom'" :min-width="2 * 14 + 48" :sort-orders="['ascending','descending']">
</el-table-column>
<el-table-column prop="name" label="姓名" sortable :min-width="2 * 14 + 48">
</el-table-column>
<el-table-column prop="address" label="地址" :min-width="2 * 14 + 48" :formatter="formatter">
</el-table-column>
</el-table>
<el-row>
<el-col :span="5">111111</el-col>
<el-col :span="5">22222222</el-col>
<el-col :span="5">3333333333</el-col>
<el-col :span="5">44444</el-col>
<el-col :span="5">5555555</el-col>
</el-row>
</template>
</div>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<script src="https://lib.baomitu.com/vue/2.5.17/vue.js">
</script>
<script src="https://unpkg.com/element-ui/lib/index.js">
</script>