I'd like to use the global objects especially proccess.env
variable in v-bind
attribute.
<base-pagination
v-model="currentPage"
:per-page="process.env.PAGE_SIZE"
:total="totalPages"
@change="handleChange"
></base-pagination>
It says
[Vue:warn] Property or method "process" is not defined on the instance
How to use the global objects(console
, process
, ...) in Vue.js template?
As far as I am concerned this is not possible because:
Whenever you are using templates in vue you are also using vue template compiler in one way or another. All template expressions will be turned into render functions, and the source code that the template compiler generates looks like this:
Note the with(this) statement at the beginning. Every reference in the remaining function will therefore always be accessed on the instance.
However you can always create a computed property and use this value: