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

新手有几个疑问😳 #31

Open
xmsz opened this issue Oct 19, 2018 · 3 comments
Open

新手有几个疑问😳 #31

xmsz opened this issue Oct 19, 2018 · 3 comments

Comments

@xmsz
Copy link

xmsz commented Oct 19, 2018

1、『Please using store.method to set method prop of data!』需要如何处理哈

我在组件里,如果没有设置pure:true 会出现这个提示,不知道有什么影响也不知道如何解决哈

2、还是不明白 pure:true的区别
我只明白,true的时候,data不会合并

仍可以修改this.store.data.xxx
却不能调用this.store.func(),调用某个store里的函数

3、组件里如果在lifetimesready生命周期的处理事件,不能够获取this.store的值
但是如果把ready拿到外面写就可以获取this.store

4、有一个很神奇的情况
页面获取数据,然后赋值
this.store.data["goodsList"] = [];
然后跳转到别的页面,在后退的时候,出现
image

但是如果使用setData就不会有这样情况

Update

这个情况,我发现复习场景是

页面A(有赋值data)=> redirectTo到页面B => redirectTo到页面A => 报错

但是如果是

页面A(有赋值data)=> navigateTo到页面B => redirectTo到页面A

就没问题

@dntzhang
Copy link
Collaborator

不能直接改data的方法,需要使用store.method传入path和方法改

纯组件的store和全局的store不是同一个

3是正常现象

4没看懂

@xmsz
Copy link
Author

xmsz commented Oct 21, 2018

不好意思 周末回复晚了
1、这是我的store文件

export default {
  data: {
    user_info: {}, 
    user_coin: function() {
      return this["user_info"]["coin"] || 0;
    }
  },
  globalData: [
    "user_info",
    "user_coin",
  ],
  /**
   * @name 打开授权弹层
   */
  authPopOpen: function() {
    this.data.auth_pop["enable"] = true;
  },
  /**
   * @name 获取用户新手教程状态
   */
  getUserStep: async function() {
    let _step = 0;
    !this.data["user_info_loaded"] && (await getUserInfo());
    _step = this.data["user_info"]["step"];
    return Promise.resolve(_step);
  }

请问authPopOpengetUserStep是属于store.method吗

2、明白了,就是这里store是组件内,不影响其他组件
3、请问这个为什么里面要不一样哈
4、这个我找时间上传代码看看哈

@dntzhang
Copy link
Collaborator

authPopOpen 和 getUserStep 不属于,user_coin 属于

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