person-mixins.ts
import { Component, Vue } from 'vue-property-decorator';

@Component
export default class PersonMixins extends Vue {
  public name: string = "Zhangsan";
  public say(msg: string) {
  	console.log(msg);
  }
}
home.vue
<template>
    <div class="home">
        <h1>This is an home page</h1>
        {{ name }}
    </div>
</template>
<script lang="ts">
import Component, { mixins } from 'vue-class-component';
import personMixins from './components/person-mixins'; //引入混入组件PersonMixins
@Component
export default class Home extends mixins(personMixins) {
    created() {
        this.say('hello');
    }
}
</script>
Logo

前往低代码交流专区

更多推荐