FrontendDeveloper.in

Vue.js question detail

How can I use imported constant in template section?

The variables need to be exposed on your data in order to use them in template section. i.e, You can't use them directly on template.

<span>
CREATE: {{CREATE_PROP}}
UPDATE: {{UPDATE_PROP}}
DELETE: {{DELETE_PROP}}
</span>
<script>
import {CREATE_DATA, UPDATE_DATA, DELETE_DATA} from 'constants';
new Vue({
...
data:{
CREATE_PROP: CREATE_DATA,
UPDATE_PROP: UPDATE_DATA,
DELETE_PROP: DELETE_DATA
}
...
})
</script>
Back to all Vue.js questions
Get LinkedIn Premium at Rs 399