import { dateFormat } from '@/common/utils.js' const install = Vue => { // 格式化金额 Vue.filter('priceFormat', function(value) { if (typeof value === 'undefined') return '未知' if (typeof value !== 'number') { value = parseFloat(value) } return value.toFixed(2) > 0 ? value.toFixed(2) : 0 }) // 格式化时间 Vue.filter('dateFormat', function(value) { if (!value) return '未知' if (value instanceof Date) { return dateFormat(value, 'yyyy-MM-dd') } else { value = new Date(value) return dateFormat(value, 'yyyy-MM-dd') } }) } export default install