Created
October 2, 2020 20:23
-
-
Save ManUtopiK/7ebb2298491698536a809343bd0c8b70 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # config.js | |
| const config = { | |
| ..., | |
| features: { | |
| ... | |
| }. | |
| ... | |
| } | |
| function feature (name) { | |
| return config.features[name] | |
| } | |
| function parse (value, fallback) { | |
| if (typeof value === 'undefined') { | |
| return fallback | |
| } | |
| switch (typeof fallback) { | |
| case 'boolean' : | |
| return !!JSON.parse(value) | |
| case 'number' : | |
| return JSON.parse(value) | |
| default : | |
| return value | |
| } | |
| } | |
| export { | |
| config | |
| } | |
| export default { | |
| install (Vue) { | |
| Vue.appConfig = config | |
| Vue.feature = feature | |
| Vue.prototype.$appConfig = config | |
| Vue.prototype.$feature = feature | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment