I've been attempting to create a reactive global $store
object using a plugin, but so far I have not been successful in getting it to function as intended.
store.ts
:
import {reactive} from "vue";
export default {
install: (app:any, options:any) => {
app.config.globalProperties.$store = reactive({})
}
}
main.ts
:
import {createApp} from 'vue';
import app from "@/vue/app.vue";
import store from "@/scripts/store";
createApp(app)
.use(store)
.mount("#app");
Although I expected the plugin to be available for use in all components, the $store
variable remains declared as an undeclared variable
when trying to utilize it within the <script setup>
tag inside a component.