var Main = {
data() {
return {
tableData: [{
date: '2016-05-03',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles'
}, {
date: '2016-05-02',
name: '',
address: 'No. 189, Grove St, Los Angeles'
}, {
date: '2016-05-04',
name: '',
address: 'No. 189, Grove St, Los Angeles'
}, {
date: '2016-05-01',
name: 'Tom',
address: 'No. 189, Grove St, Los Angeles'
}]
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')
@import url("//unpkg.com/element-ui@2.4.11/lib/theme-chalk/index.css");
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui@2.4.11/lib/index.js"></script>
<div id="app">
<template>
<el-table :data="tableData" style="width: 100%">
<el-table-column prop="date" label="Date" width="180">
</el-table-column>
<el-table-column prop="name" label="Name" width="180">
<template slot-scope="scope">
{{scope.row.name || '-'}}
</template>
</el-table-column>
<el-table-column prop="address" label="Address">
</el-table-column>
</el-table>
</template>
</div>
I know If I use 'template' tag I can convert null data as '-'.
now let's suppose that I have more than 100 tables and I don't know which cells can be null.
putting 'template' to all el-table-columns will be very hard work and inefficient way.
I want to know is there any way that I can change empty cells as '-' at the same time. help me guys
jsfiddle