wxMiniStore
一个基于原生小程序的Mini全局状态管理库,跨页面/组件的数据共享。
1、安装
npm init
npm install wxministore -S
2、微信开发者工具中勾选‘使用npm模块’
3、工具->构建npm
4、项目中引入![在这里插入图片描述](https://img-blog.csdnimg.cn/2da31b54a452410bb8c31c776638f8e8.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQW7mu7Tppa3lhL8=,size_20,color_FFFFFF,t_70,g_se,x_16)
5、使用
1)app.js中引入store.js
2)store.js中可以引入其他模块存放全局状态的文件
3)其他模块的全局变量的写法
4)更改全局变量的值,在需要使用的组件中,加入useStore: true,表示当前页面或组件可用$state。
5)使用
参考文档:https://blog.csdn.net/qq_35173602/article/details/82349742