import useBreadcrumbStore from '@/store/breadcrumbStore'
导入您的store
import { createPinia } from "pinia"
const store = useBreadcrumbStore(createPinia())
导入createPinia,在初始化store的时候放入createPinia()
export default defineNuxtRouteMiddleware((to, from) => {
console.log(to.path, from.path);
store.navigationObj.push()
})
然后就可以使用store了!!!
全部代码
import useBreadcrumbStore from '@/store/breadcrumbStore'
import { createPinia } from "pinia"
const store = useBreadcrumbStore(createPinia())
export default defineNuxtRouteMiddleware((to, from) => {
console.log(to.path, from.path);
store.navigationObj.push()
})