I have a folder structure like this
--Page
-group.vue
--Services
-groupMixin.ts
script of group.vue
<script lang="ts">
import { Vue, Component, Mixins } from 'vue-property-decorator'
import { GroupMixin } from '../../services/groupMixin';
@Component
export default class Group extends Mixins(GroupMixin) {
created () {
console.log(this.test)
}
}
</script>
code of groupMixin.ts
import { Vue } from 'vue-property-decorator'
//creating mixins.
export class GroupMixin extends Vue {
test: string = 'sss'
}
I am facing two problems here.
First, to import a ts file i used ../../, is there any way to use ./ or @/. Without using lang="ts", i can import a js file like this @/services/...
Second, not able to access the varaible test which i declared in groupmixin.ts.
If you don't use vue-class-component (currently i'm not beacase it dosen't work well with setup/ composition api) you can use defineComponent as mixin and it's work in vue 3 with typescript
example of mixin:
yor_mixin.ts
and component