npm i vue-di-helper
# OR
yarn add vue-di-helper
# OR
pnpm add vue-di-helper
import { Ref, ref } from "vue";
export class SomeService {
// ...
count: Ref<number>;
constructor() {
this.count = ref(0);
}
increase = () => {
this.count.value++;
};
// ...
}
<template></template>
<script setup lang="ts">
//...
import { provide } from "vue-di-helper";
import { SomeService } from "path/to/some.service.ts";
provide(SomeService);
//...
</script>
import { inject } from "vue-di-helper";
import SomeService from "./some.service.ts";
const someService = inject(SomeService);