以下是实现方式,可把以下代码直接拷贝到项目中使用
<script>
filters: {
moneys: function(e) {
//这里返回带金钱符号的字符串
return "$" + e + ".00";
},
time: function(timestamp) {
var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
var Y = date.getFullYear() + "-";
var M =
(date.getMonth() + 1 < 10
? "0" + (date.getMonth() + 1)
: date.getMonth() + 1) + "-";
var D = date.getDate() + " ";
var h = date.getHours() + ":";
var m = date.getMinutes() + ":";
var s = date.getSeconds();
// return Y+M+D+h+m+s;
//这里返回时间的年月日时分秒,可按项目需求进行修改
return Y + M + D;
},
lowText:function (val) {
var text = val;
if(val.length>60){
text = val.slice(0,60)+'...';
}
return text;
}
}
关于时间格式转化的方法:
crtTimeFtt: function (val) {
if (val != null) {
var date = new Date(val);
return date.getFullYear()+'-'+parseInt(date..getMonth() + 1)+'-'+.getDate();
}
},
</script>