【发布时间】:2020-07-23 21:49:40
【问题描述】:
我遇到以下问题,希望有人可以帮助我:
Fetch 在第一次加载时不起作用(也不是在重新加载时)。它仅在客户端(当我在路由之间移动时)有效。
我读过 watchQuery 可以提供帮助,但不明白为什么以及如何使用它。
<script>
export default {
async fetch() {
const userId = await this.$nuxt.context.store.state.auth.authUser.userId
await this.$store.dispatch('case/fetchMyCases', userId.uid)
await this.$store.dispatch('case/fetchMyPendingCases', userId.uid)
...
即使我直接导入和使用 firebase/auth 也不起作用。
<script>
import * as firebase from 'firebase/app'
import 'firebase/auth'
export default {
async fetch() {
const userId = await firebase.auth().currentUser
await this.$store.dispatch('case/fetchMyCases', userId.uid)
await this.$store.dispatch('case/fetchMyPendingCases', userId.uid)
...
有人对此有什么建议吗?我真的很感激。
谢谢!
【问题讨论】:
-
你是在通用模式下使用nuxt,还是没有?
-
是的,我使用的是通用模式。