facing-dev/vue-facing-decorator

Issues using mixins

Closed this issue · 3 comments

rs3d commented

Hi,

I'm trying to create a working class component with a mixin but I'm receiving following error:
image

I've tried already multiple ways but can't get it to work.

Example:
https://stackblitz.com/edit/vitejs-vite-solmwi?file=src%2Fcomponents%2FHelloWorld.vue

When I remove the 'MyMixin' in L:14 it's rendering
image

As I understand using "experimentalDecorators": true, as tsconfig setting I don't need to wrap the default export with toNative.
Even using toNative in my example doesn't help.

Hi @rs3d - I think you have a couple different options:

  1. You could change your Mixin to be exported from a .ts file instead of a .vue file and still use the extends mixins(MyMixin) method:
  2. You could continue exporting the Mixin from a .vue file and use @Component({ mixins: [MyMixin] }) instead:

Do either of those options work for you?

Hi @rdhelms, thanks for the helpful answer and these two ways of solving it. I'm upgrading a vue2 project, and besides my current approach of using the options-api in most cases, your answer will come in handy for some components I don't want to refactor. I wouldn't have thought that .ts-ext is helping here.

这个问题解决了吗?我看目前最新版本还在报错?