The environment variables are defined in config/
directory prod.env.js
and dev.env.js
, how to get those variable on .vue
file?
I've tried using process.env.MY_VAR
assuming it's nodejs built-in library, it gives an error:
[======= ] 34% (building modules){ SyntaxError: Unexpected token (1:5)
The minimal code in .vue
file:
<template>
<q-layout>
<div class="layout-view">
<button class="primary" @click="foo">
<i class="on-left">lock</i> Login
</button>
</div>
</q-layout>
</template>
<script>
export default {
data() {
return { url: '' }
}
methods: {
foo: function() {
this.url = process.env.MY_VAR // no error if commented
}
}
}
</script>
What's the correct way to get those environment variable?