// 格式化方法
function currencyFormat(value, symbol = ‘¥‘) {
return symbol + value;
}
// 导出多个
export { currencyFormat }
import * as filters from ‘./tools/filters‘;
// 注册全局过滤器
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
// 在文本插值中的默认使用
{{ currency | currencyFormat }} // 结果:¥12.7
// 传参的方式
{{ currency | currencyFormat(‘$‘) }} // 结果: $12.7
原文:https://www.cnblogs.com/yuxi2018/p/14635441.html