0👍
✅
Define types
in your component’s data
, props
, or computed
. And define getType
in methods
data: function() {
return {
types: [{"name":1,"type":"Daily"},
{"name":2,"type":"Bi-Weekly"},
{"name":3,"type":"Monthly"},
{"name":4,"type":"Yearly"},
{"name":5,"type":"Other"}]
}
}
methods: {
getType(id): {
return this.types.filter(e => e.name == id)[0].type
}
}
If they are defined outside of the component, and you don’t need to call them from a Vue template, then don’t use this
at all. In that case they will be at global
or module
scope.
Source:stackexchange.com