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

如何多个页面共享一个store使用 #142

Closed
nanhupatar opened this issue May 8, 2023 · 5 comments
Closed

如何多个页面共享一个store使用 #142

nanhupatar opened this issue May 8, 2023 · 5 comments

Comments

@nanhupatar
Copy link
Contributor

目前尝试了bind相同的viewkey,不行。请问有什么方式能跨页面使用吗

@nanhupatar
Copy link
Contributor Author

@dntzhang

@nanhupatar
Copy link
Contributor Author

nanhupatar commented May 9, 2023

目前解决方案 ,可以实现多个页面绑定同一store,暂不清楚有什么弊端
onShow() {
this.setData({ ...Store.data }, () => {
Store.bind('page', this);
});
},

@dntzhang
Copy link
Collaborator

1.你可以先new 出来再import到 各个store

2.westore 没有斩断 store 之间的通讯吧,这个可以开发者自己组织依赖关系、发布订阅什么的。

model之间可以多对多互相依赖,store之间可以多对多互相依赖,model和store之间可以多对多互相依赖。

westore只是斩断model和view之间的依赖。

@Megasu
Copy link

Megasu commented Jul 18, 2023

请问官方能出多个页面共享一个 store 例子吗?

现在官方的 example 只是在一个页面中用到 store,这样的 store 抽离在单个页面中使用感觉是非必须的。
但 原生小程序的多个页面共享一个 store 的需求应该更常见,多页面共享用户信息,共享购物车数量等。

所以冒昧问一下,官方是否有计划出品类似 pinia , vuex 这类全局状态管理库,方便使用原生小程序的开发者使用。🌹🌹

@wuhao1477
Copy link

请问官方能出多个页面共享一个商店的例子吗?

现在官方的例子只是在一个页面中可用存储,这样的存储抽离在单个页面中使用感觉是非必须的。 但初期小程序的多个页面共享一个存储的需求应该更常见,多页面共享用户信息,共享购物车数量等。

所以冒昧问一下,官方是否有计划出品类似 pinia , vuex 这类全局状态管理库,方便使用简单小程序的开发者使用。🌹🌹

请问一下“多页面共享用户信息,共享购物车数量”等需求的话目前您的解决方案用的是什么呢?

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

4 participants