vue property decorator mixins

Solutions on MaxInterview for vue property decorator mixins by the best coders in the world

showing results for - "vue property decorator mixins"
Emerson
19 Feb 2018
1// mixins.js
2import Vue from 'vue'
3import Component from 'vue-class-component'
4
5// You can declare mixins as the same style as components.
6@Component
7export class Hello extends Vue {
8  hello = 'Hello'
9}
10
11@Component
12export class World extends Vue {
13  world = 'World'
14}
15
16// Component.vue
17import Component, { mixins } from 'vue-class-component'
18import { Hello, World } from './mixins'
19
20// Use `mixins` helper function instead of `Vue`.
21// `mixins` can receive any number of arguments.
22@Component
23export class HelloWorld extends mixins(Hello, World) {
24  created () {
25    console.log(this.hello + ' ' + this.world + '!') // -> Hello World!
26  }
27}