{ defineStore } from "pinia";
                  
                  
                  import home from "@/views/Home.vue"
                  
                  
                  export const useTestStore = defineStore("TestStore", {
                  
                  
                    state: () => {
                  
                  
                      return {
                  
                  
                        home,
                  
                  
                      }
                  
                  
                    }
                  
                  
                    //actions
                  
                  
                    //getters
                  
                  
                    
                  
                  
                  })
                  
                  
                  В App.vue делаю: 
                  
                  
                  import { useTestStore } from "@/stores/TestStore"
                  
                  
                  useTestStore()
                  
                  
                  
                  
                  
                  export default {
                  
                  
                    name: 'App',
                  
                  
                    data(){
                  
                  
                      return{
                  
                  
                      useTestStoreX: useTestStore.sta
                  
                  
                      }
                  
                  
                    }
                  
                  
                  ...
                  
                  
                  В Home.vue делаю: 
                  
                  
                  data(){
                  
                  
                      return{
                  
                  
                        sta: 1
                  
                  
                      }
                  
                  
                    },
                  
                  
                  Но в console при обновлении выдает ошибку: 
                  
                  
                  Uncaught Error: [🍍]: getActivePinia was called with no active Pinia. Did you forget to install pinia?
                  
                  
                    const pinia = createPinia()
                  
                  
                    app.use(pinia)
                  
                  
                  This will fail in production. 
                  
                  
                  ...
                  
                  
                
У тебя в ошибке всё написано же. Пропиши const pinia = createPinia() app.use(pinia)
Вот main.js файл: import { createApp } from 'vue' import App from './App.vue' import { createPinia } from 'pinia' const pinia = createPinia() import router from "./router/index.js"; const app = createApp(App) app.use(pinia) app.use(router) app.mount('#app')
Попробуй пересобрать код
ну дык зачем ты стор вызываешь вне компонента?
Обсуждают сегодня