nuxt-global-var
Version:
if you have some variables that are the same in all languages or you want to define variables by using json instead of .env, let's use this package!
35 lines (33 loc) • 695 B
Markdown
A module for nuxtjs that make defining and using variables in component easier by using js object or json file.
`npm install nuxt-global-var`
Firstly, you need to add `nuxt-global-var` to your Nuxt config.
```javascript
// nuxt.config.js
{
modules: [
[
'nuxt-global-var',
{
data: {HOST: 'shinryak.site'}
}
]
]
}
```
Now, you can use `nuxt-global-var` in your component
```html
<templete>
<h1>
Test nuxt-global-var in component
</h1>
<p>
{{ $get('HOST') }}
</p>
</templete>
```
[](https://github.com/minhchi3103/nuxt-global-var/blob/master/LICENSE "MIT License")