Using enums anywhere which is more advanced than typescript enum
$ npm install nuxt-router-enum
- module configuration
// nuxt.config.js
export default {
modules: [
[
'nuxt-router-enum',
{
/* module options */
},
],
],
// or
enum: {
/* module options */
path: '~/enums',
fileName: 'index.js',
},
};
- enums configuration
// ~/enums/index.js
export default {
FOO: [
{
key: 'FOO_KEY_1',
text: 'foo text 1',
value: 1,
},
{
key: 'FOO_KEY_2',
text: 'foo text 2',
value: 2,
},
],
};
-
path
Location of your route file
- Type:
string
- Default:
~
- Type:
-
fileName
File name of your routes configuration in
path
Must export valid Vue routes- Type:
string
- Default:
index.js
- Type:
-
routerOptions
Same as
vue-router
router options