vue跳转页面时第一子路由页面偶尔会显示Pinia中的action not a function,而跳转的另一个同级路由页面一定会报错 对应的pinia action is not a function 都是刷新后就有了,求解答
页面js:
import { useEnterStore } from '@/store/main/userenter/userEnter'
import { storeToRefs } from 'pinia'
import { ref } from 'vue'
import { formatUTC } from '@/utils/format'
import { localCache } from '@/utils/cache'
const userId = localCache.getCache('userId')
//const userStore = useUserStore()
const userEnterStore = useEnterStore()
//const userId = userStore.userId
const currentPage = ref(1)
const webpageSize = ref(6)
//查询
function fetchEnterListData(queryInfo: any = {}) {
//获取offset和size
const pageSize = webpageSize.value
const pageIndex = currentPage.value
const info = { pageIndex, pageSize }
//带参数查询时将数组组合在一起
const totalquery = { ...info, ...queryInfo }
userEnterStore.postUserEnterListAction(totalquery)
}
fetchEnterListData({ userId: userId.id })
const { enterList, enterTotalCount } = storeToRefs(userEnterStore)
```路由
import { useEnterStore } from '@/store/main/userenter/userEnter'
import { storeToRefs } from 'pinia'
import { ref } from 'vue'
import { formatUTC } from '@/utils/format'
import { localCache } from '@/utils/cache'
const userId = localCache.getCache('userId')
//const userStore = useUserStore()
const userEnterStore = useEnterStore()
//const userId = userStore.userId
const currentPage = ref(1)
const webpageSize = ref(6)
//查询
function fetchEnterListData(queryInfo: any = {}) {
//获取offset和size
const pageSize = webpageSize.value
const pageIndex = currentPage.value
const info = { pageIndex, pageSize }
//带参数查询时将数组组合在一起
const totalquery = { ...info, ...queryInfo }
userEnterStore.postUserEnterListAction(totalquery)
}
fetchEnterListData({ userId: userId.id })
const { enterList, enterTotalCount } = storeToRefs(userEnterStore)
```javascript
```报错
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/549034916886196.png "#left")