I can create a constant through a store in my vuejs application, but i don\'t think it is a good practice.what is other way to do the same?
You can use the method
const State= Object.freeze({ Active: 1, Inactive: 2 });
export default {
data() {
return {
State,
state: State.Active
};
},
methods: {
method() {
return state==State.Active;
}
}
}
or
const State= Object.freeze({ Active: 1, Inactive: 2 });
export default {
data() {
return {
State_: State,
state: State.Active
};
},
methods: {
method() {
return state==State_.Active;
}
}
}