getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)
时间: 2024-01-13 07:19:51 浏览: 455
14.(vue3.x+vite)组件间通信方式之pinia.rar
根据提供的引用内容,"getActivePinia()"被调用时没有活动的Pinia实例。这通常是因为在调用"app.use(pinia)"之前尝试使用存储。为了解决这个问题,你需要确保在使用存储之前先调用"app.use(pinia)"。
以下是一个示例代码,展示了正确使用Pinia的方法:
```javascript
import { createApp } from 'vue'
import { createPinia } from 'pinia'
const app = createApp()
const pinia = createPinia()
app.use(pinia)
// 在调用"getActivePinia()"之前,确保已经调用了"app.use(pinia)"
const store = pinia.getActi
阅读全文