1 Star 0 Fork 0

Grain1915 / wxproject_grain_music

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
一些笔记.txt 716 Bytes
一键复制 编辑 原始数据 按行查看 历史
Grain1915 提交于 2021-06-18 21:44 . 完善音乐详情,并增加了npm
页面间的几种通信方式
1.使用globalData
现在app.js中的data中声明需要传递的参数如index,
在page中使用 const app = getApp();
app.globalData.index调用
2.使用pubSub发布
<0>1.使用npm install pubsub-js安装
2.
<1>订阅方:PubSub.subscribe(事件名,事件回调)
订阅方是接受数据的一方
<2>发布方:PbuSub.publish(事件名,提供的数据)
发布方是提供数据的一方
3.使用getcurrentPage()
通过let currentPages = getCurrentPages();
根据得到的currentPages 数组的__route__判断页面
比如我想的数据在第一个数组里
那么currentPages[0].__data__中便是我们想要的数据
具体根据实际情况判断
1
https://gitee.com/Grain1915/wxproject_grain_music.git
git@gitee.com:Grain1915/wxproject_grain_music.git
Grain1915
wxproject_grain_music
wxproject_grain_music
master

搜索帮助