鍍金池/ 問答/HTML5  HTML/ vue的el-table怎么過濾綁定的數(shù)據(jù)

vue的el-table怎么過濾綁定的數(shù)據(jù)

<el-table-column prop="modifyTime" label="修改時間">
                </el-table-column>

想用下面自定義的過濾器 該怎么寫

//自定義過濾器過濾時間    作用:將1415674835697的時間戳轉(zhuǎn)為 yyyy/MM/dd 格式時間
Vue.filter("timeForm",function(time){
    time =(typeof time=='string')?parseInt(time) : time
    let date=new Date(time)
    return util.formateDate(date,'yyyy/MM/dd');
});

問題描述

問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法

相關(guān)代碼

// 請把代碼文本粘貼到下方(請勿用圖片代替代碼)

你期待的結(jié)果是什么?實際看到的錯誤信息又是什么?

回答
編輯回答
念初

<el-table-column prop="createDate" label="創(chuàng)建時間">

                <template slot-scope="scope">
                 {{scope.row.createDate|timeForm}}
               </template>
            </el-table-column>
2018年9月12日 09:49
編輯回答
別逞強
<el-table-column
            prop="date"
            label="發(fā)布時間">
            <template slot-scope="scope">
              {{$utils.toTimeFormat(scope.row.date)}}
            </template>
</el-table-column>
2018年5月15日 05:32