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

错误:App.vue中globalData未定义导致跳转其他页面失败 #179

Open
daonan233 opened this issue Jul 8, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@daonan233
Copy link
Contributor

  • 具体报错:TypeError: Cannot read property 'globalData' of undefined
  • 除此之外,还缺少userInfo的选项(代码上文有提及),已手动添加
 userInfo: {
      avatar: '',
      nickname: '',
    },

但无效果,后续继续调整

  • 当前globalData部分修正如下,仍未解决问题,预测解决完该问题即可实现正常跳转
globalData: {
    userInfo: {
      avatar: '',
      nickname: '',
    },
    watch(method) {
      const obj = this;
      Object.defineProperty(obj, 'data', {
        configurable: true,
        enumerable: true,
        set(value) {
          if (value.avatar) {
            this.$set(this.userInfo, 'avatar', value.avatar);
          }
          if (value.nickname) {
            this.$set(this.userInfo, 'nickname', value.nickname);
          }
          method(value);
        },
        get() {
          return this;
        },
      });
    },
  },

@daonan233 daonan233 added the bug Something isn't working label Jul 8, 2023
@lin594
Copy link
Member

lin594 commented Jul 31, 2023

原本的第24行调整到第35行试一试

await getLoginStatus();

或者就是去掉await?我感觉可能和这个有关系?因为他阻塞在这里,让他无法正常设置globalData之类的字段,读取的时候就出错了?

@lin594
Copy link
Member

lin594 commented Oct 27, 2023

这个为啥就关闭了,现在解决了这个问题么))(我不太清楚

@lin594 lin594 reopened this Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants