用來格式化內容 |
Function(row, column, cellValue) |
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>AdminLTE 2 | Morris.js Charts</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="../plugins/elementUI/elementUI.css">
<style>
</style>
</head>
<body class="">
<div id="demo">
<el-table
:data="tableData3"
style="width: 100%"
height="250">
<el-table-column
fixed
prop="date"
label="日期"
width="150"
:formatter="formatDate"
>
</el-table-column>
<el-table-column
prop="name"
label="姓名">
</el-table-column>
<el-table-column
prop="province"
label="省份">
</el-table-column>
<el-table-column
prop="city"
label="市區">
</el-table-column>
<el-table-column
prop="address"
label="地址">
</el-table-column>
<el-table-column
prop="zip"
label="郵編">
</el-table-column>
</el-table>
</div>
<script src="../js/vue.js"></script>
<script src="../plugins/elementUI/elementUI.js"></script>
<script>
var demo = new Vue({
el: '#demo',
data: {
tableData3: [{
date: '2016-05-03',
name: '王小虎',
province: '上海',
city: '普陀區',
address: '上海市普陀區金沙江路 1518 弄',
zip: 200333
}, {
date: '2016-05-02',
name: '王小虎',
province: '上海',
city: '普陀區',
address: '上海市普陀區金沙江路 1518 弄',
zip: 200333
}, {
date: '2016-05-04',
name: '王小虎',
province: '上海',
city: '普陀區',
address: '上海市普陀區金沙江路 1518 弄',
zip: 200333
}, {
date: '2016-05-01',
name: '王小虎',
province: '上海',
city: '普陀區',
address: '上海市普陀區金沙江路 1518 弄',
zip: 200333
}, {
date: '2016-05-08',
name: '王小虎',
province: '上海',
city: '普陀區',
address: '上海市普陀區金沙江路 1518 弄',
zip: 200333
}, {
date: '2016-05-06',
name: '王小虎',
province: '上海',
city: '普陀區',
address: '上海市普陀區金沙江路 1518 弄',
zip: 200333
}, {
date: '',
name: '王小虎',
province: '上海',
city: '普陀區',
address: '上海市普陀區金沙江路 1518 弄',
zip: 200333
}]
},
methods: {
formatDate(row, column, cellValue){
//return row.date == "2016-05-04" ? '男' : row.sex == 0 ? '女' : '未知';
//格式化是針對表格內容即便data數據
var newDate = row.date== "" ? "-" : row.date.replace(/-/g,"/")
return newDate
}
}
})
</script>
</body>
</html>