config.js 478 B

123456789101112131415161718192021
  1. import mergeConfig from '@/config'
  2. /**
  3. * 配置文件工具类
  4. * mix: 如需在项目中获取配置项, 请使用本工具类的方法, 不要直接import根目录的config.js
  5. */
  6. export default {
  7. // 获取全部配置
  8. all() {
  9. return mergeConfig
  10. },
  11. // 获取指定配置
  12. get(key, def = undefined) {
  13. if (mergeConfig.hasOwnProperty(key)) {
  14. return mergeConfig[key]
  15. }
  16. console.error(`检测到不存在的配置项: ${key}`)
  17. return def
  18. }
  19. }