Similar to the backend Config, EggBornJS also implements the frontend Config at the module level

  1. Module can specify its own configuration
  2. The configuration at project level can override the one at module level

Definition of Config

src/module/test-party/front/src/config/config.js

export default {
  message: 'Hello World',
  markCount: 2,
};

Usage of Config

Same Module

src/module/test-party/front/src/kitchen-sink/pages/guide.vue

onPerformClick4() {
  const params = {
    message: this.$config.message,
    markCount: this.$config.markCount,
  };
  return this.$api.post('kitchen-sink/guide/echo4', params).then(data => {
    this.message4 = data;
  });
},

Across Module

If used across modules, the way is as follows:

this.$meta.module.use('test-party', module => {
  const message = this.$meta.config.modules['test-party'].message;
});
Name Description
$meta.module.use The frontend of a module is usually loaded asynchronously, so before using the module’s Config, you need to ensure that the module has been loaded
$meta.config.modules[moduleName] Get the Config of the specified module

Override Config

Also can use project level config to override module level config

src/front/config/config.js

export default{
  modules: {
    'test-party': {
      message: 'Hello World!',
      markCount: 3,
    },
  },
};