hawtim.github.io icon indicating copy to clipboard operation
hawtim.github.io copied to clipboard

vue-property-decorator + ts 使用 mixins

Open hawtim opened this issue 4 years ago • 0 comments

背景

一个需求,要在一个大模块下的几个子页面里添加相同的筛选项,有一些通用的方法,如果在每个子页面下写会造成冗余代码。在 vue + ts + vpd 的技术选型下,记录下使用方法。

component.vue

<script lang="ts">
import { Component, Mixins } from 'vue-property-decorator';
import filterMixin from '../mixin';

@Component
export default class ExternalPointList extends Mixins(filterMixin) {}

mixin.ts

import { Component, Vue } from 'vue-property-decorator';

@Component
export default class FilterMixin extends Vue {}

hawtim avatar Jan 21 '22 12:01 hawtim