vue typescript mixins混入

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 pageh1>
        {{ 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>

你可能感兴趣的:(vue,typescript,vue,typescript,mixins,混入)