vue typescript mixins混入
person-mixins.tsimport { Component, Vue } from 'vue-property-decorator';@Componentexport default class PersonMixins extends Vue {public name: string = "Zhangsan";public say(msg: string) {console.log(m
·
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>
更多推荐
已为社区贡献24条内容
所有评论(0)