Saturday, May 25, 2024
 Popular · Latest · Hot · Upcoming
7
rated 0 times [  11] [ 4]  / answers: 1 / hits: 75566  / 7 Years ago, wed, march 8, 2017, 12:00:00

I tried to defined a const in a *.vue file:


<script>
export const CREATE_ACTION = 1,
export const UPDATE_ACTION = 2
<script>

And use them in the template:


<template>
...
<select :disabled="mode === UPDATE_ACTION">
....
</template>

But it does not work. How can I use const in a Vue template?


More From » vue.js

 Answers
47

Expose them on your data:


new Vue({
data:{
CREATE_ACTION: CREATE_ACTION,
UPDATE_ACTION: UPDATE_ACTION
}
})

[#58634] Monday, March 6, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
morganm

Total Points: 626
Total Questions: 95
Total Answers: 95

Location: South Sudan
Member since Sun, Jul 11, 2021
3 Years ago
;