[Vuejs]-Is it possibile to create a Typescript module that export mixins?

0👍

The implementation obviously depends on the library you are using.

But you can extract all the code of your mixin into another component/file. Both versions are using the library vue-class-component.

Version 1

@Component
export default class MyMixins extends Vue {}

and then use inheritance in a child component:

@Component
export default class ChildClass extends MyMixins {}

Version 2

You can use the mixins function:

import Component, { mixins } from 'vue-class-component'

@Component()
export default class ChildClass extends mixins(MyMixin1, MyMixin2) {}

For reference, you can use the document.

Leave a comment