Vue.filter(id,[definition]){string} id
{Function}[definition]
main.js 添加
Vue.filter('moneyFilters',function(value){let val = value
let result ="";if(val >=1){
result = val
}elseif(val <1&& val >0){
result =(val *10000).toFixed()}else{
result = val;}return result;})
Vue.filter('moneyFilters',function(value){let val = value
let result ="";if(val >=1){
result ="亿";}elseif(val <1&& val >0){
result ="万";}else{
result ="元";}return result;})//整数留下2位letmoney=value=>{if(!value)return"0.00";
value = Math.round(parseFloat(value)*100)/100;let xsd = value.toString().split(".");if(xsd.length ==1){
value = value.toString()+".00";return value;}return value
}//千位转化letThousands=value=>{return(value ||0).toString().replace(/(\d)(?=(?:\d{3})+$)/g,'$1,');}//时间戳转换letformDate=value=>{let date =newDate(value *1000);//时间戳为10位需*1000,时间戳为13位的话不需乘1000letY= date.getFullYear()+'-';letM=(date.getMonth()+1<10?'0'+(date.getMonth()+1): date.getMonth()+1)+'-';letD= date.getDate()+' ';let h = date.getHours().length <=1?'0'+ date.getHours()+':': date.getHours()+':';let m = date.getMinutes()<10?'0'+ date.getMinutes()+':': date.getMinutes()+':';let s = date.getSeconds()<10?'0'+ date.getSeconds(): date.getSeconds();returnY+M+D+ h + m + s;}export{
money,
Thousands,
formDate
}