facing-dev / vue-facing-decorator

Vue typescript class component decorators
MIT License
368 stars 32 forks source link

Class extends value #<Object> is not a constructor or null #133

Open markus-petelinc opened 1 month ago

markus-petelinc commented 1 month ago

When extends components, the following problem occurs: Class extends value # is not a constructor or null

Both classes are in seperated .vue files and contain template and css.

With Vue2 Class Decorators it was possible to extends .vue files with the template directly and the template and css was taken over from the extended class.

Does anyone have a solution for this problem without splitting .vue files into .ts, .html, .css ....

<script lang="ts">
import {Vue, Component, Inject} from 'vue-facing-decorator';

@Component
export default class Main extends Vue {

}
</script>

<template>
    <main class="responsive">
        <slot></slot>
    </main>
</template>

<style scoped>

</style>
<script lang="ts">
import {Vue, Component, Inject} from 'vue-facing-decorator';
import Main from "@/components/Main.vue";

@Component
export default class Main2 extends Main {

}
</script>
mattkenefick commented 2 days ago

I've been exploring this too. I think it's because you're exporting the default.

That was common in Vue2 but now you have to export the class and component separately if you want to extend multiple, so like this.

<script lang="ts">
// Main.vue
import { Component, toNative } from 'vue-facing-decorator';

@Component
export class Main extends Vue {

}
</script>
<script lang="ts">
// Main2.vue
import { Main } from './Main';
import { Component, toNative } from 'vue-facing-decorator';

@Component
export class Main2 extends Main {

}
</script>