Similar to the backend Config
, EggBornJS also implements the frontend Config
at the module level
- Module can specify its own
configuration
- The
configuration
atproject level
can override the one atmodule level
Definition of Config
src/suite-vendor/test-party/modules/test-party/front/src/config/config.js
- 1export default {
- 2 message: 'Hello World',
- 3 markCount: 2,
- 4};
Usage of Config
Same Module
src/suite-vendor/test-party/modules/test-party/front/src/kitchen-sink/pages/guide.vue
- 1onPerformClick4() {
- 2 const params = {
- 3 message: this.$config.message,
- 4 markCount: this.$config.markCount,
- 5 };
- 6 return this.$api.post('kitchen-sink/guide/echo4', params).then(data => {
- 7 this.message4 = data;
- 8 });
- 9},
Across Module
If used across modules, the way is as follows:
- 1this.$meta.module.use('test-party', module => {
- 2 const message = this.$meta.config.modules['test-party'].message;
- 3});
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.{scene}.js
- 1export default{
- 2 modules: {
- 3 'test-party': {
- 4 message: 'Hello World!',
- 5 markCount: 3,
- 6 },
- 7 },
- 8};
Comments: