Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

从“发帖页面”直接切换到“个人中心”报错 #156

Open
jackou2077 opened this issue Jan 3, 2024 · 1 comment
Open

从“发帖页面”直接切换到“个人中心”报错 #156

jackou2077 opened this issue Jan 3, 2024 · 1 comment

Comments

@jackou2077
Copy link

提示Required request parameter 'followingId' for method parameter type Integer is not present

@ReturnTmp
Copy link

先说解决方案,pages/user/_account.vue 中的 mounted() 函数直接删掉,然后原本的 fetch() 修改如下

async fetch() {
    let {store, params, query, error} = this.$nuxt.context;
    params.page = query.page || 1
    await Promise.all([
      store
        .dispatch('user/fetchDetail', params)
        .catch(err => error({statusCode: 404})),
      store.dispatch('user/fetchUserExtend', params),
      store.dispatch('user/fetchArticleList', params),
      store.dispatch('user/fetchPortfolioList', params),
      store.dispatch('user/fetchFollowerList', params),
      store.dispatch('user/fetchFollowingList', params)
    ])
    let _ts = this;
    this.$store.commit('setActiveMenu', 'user');
    if (_ts.loggedIn) {
      await _ts.$axios.$get('/api/follow/is-follow', {
        params: {
          followingId: _ts.user.idUser,
          followingType: 0
        }
      }).then(function (res) {
        _ts.$set(_ts, 'isFollow', res);
      })
    }
  }

原因就是 fetch 是更新 followingId 的,然后 mounted 是使用 followingId 的,但是执行顺序是先执行 mounted 再执行 fetch,导致没找到 followingId

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants