Vue.use(IncludeConstants);// In components options
{
$consts: {
MAX_LENGTH: 40
}
}<input max-length="MAX_LENGTH">this.MAX_LENGTH| export default { | |
| install (Vue) { | |
| Vue.mixin({ | |
| created: function () { | |
| if (this.$options.$consts) { | |
| Object.entries(this.$options.$consts) | |
| .forEach(([key, value]) => { | |
| Object.defineProperty(this, key, { | |
| value, | |
| writable: false | |
| }); | |
| }); | |
| } | |
| } | |
| }); | |
| } | |
| }; |