在main.js把自定义的公共方法作为过滤器全局导入vue

Vue 实例全局导入过滤器:
Vue.filter('functionName',function)
import * as type from './type' =>全部导入
import {get,set} from './type' =>导入type文件里的get,set方法
1,import * as filters from './helper/filters'导入组建(定义好的方法)
2,import Vue from 'vue'导入vue
3,全局导入
 Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
  })
filters =>{name1:f,name2:f,name3:f.........}name1:方法名,f对应的函数
 Object.keys =>获取对象的属性名,返回一个数组
key =>数组的每一项值
forEach =>遍历数组,key:数组的每一项内容(name1,,,,,,)
array.sort() =>数组按字母先后排序
原文地址:https://www.cnblogs.com/LWJ-booke/p/8491360.html