? ????? ?? ????? ?? ??? ???? ?? ??? ???????.
?? ?????? ??? ???? ?? ??
url ???? ??
? ???? ??? ?????.
index1 ???
<navigator url="/pages/index2/index2?name=海賊王">頁面2</navigator>
??
wx.navigateTo({ url: "/pages/index2/index2?name=海賊王" })
index2 ???
onLoad: function (options) { console.log(options);// { name : 海賊王} },
index2
? ?? ???? ?? onLoad?? ??? ????? ?? ? ??? ?? ???? ???. [?? ?? ????: ?? ???? ?? ????index2
是tabbar頁面,那么無法在onLoad中獲取頁面參數(shù)。【相關(guān)學習推薦:小程序開發(fā)教程】
事件通道 EventChannel
如果一個頁面由另一個頁面通過 wx.navigateTo
打開,這兩個頁面間將建立一條數(shù)據(jù)通道:
- 被打開的頁面可以通過
this.getOpenerEventChannel()
方法來獲得一個EventChannel
對象; wx.navigateTo
的success
回調(diào)中也包含一個EventChannel
對象。
這兩個 EventChannel
對象間可以使用 emit
和 on
方法相互發(fā)送、監(jiān)聽事件。
index1.wxml
<view> 來自于頁面2 傳遞的數(shù)據(jù): {{msg}} </view>
index1.js
Page({ data: { msg: "" }, onLoad: function () { // 1 跳轉(zhuǎn)到頁面2 wx.navigateTo({ url: "/pages/index2/index2", // 2 在成功的回調(diào)函數(shù)中獲取事件通道對象 success: ({ eventChannel }) => { // 3 監(jiān)聽自定義事件 eventChannel.on("data", (e) => { // 4 獲取頁面2傳遞過來的數(shù)據(jù) 設(shè)置到 data中 this.setData({ msg: e.name }) }) } }); }, })
index2.js
Page({ onLoad: function () { // 被使用 wx.navigatorTo打開的頁面獲取獲取到一個事件通道對象 const EventChannel = this.getOpenerEventChannel(); // 觸發(fā)事件和傳遞參數(shù)到 頁面1中 EventChannel.emit("data", { name: '海賊王' }); } })
本地存儲
小程序中的本地存儲用法類似web中,可以實現(xiàn)在整個應(yīng)用中獲取數(shù)據(jù)和存儲數(shù)據(jù)
index1.js
wx.setStorageSync('data', {name:'海賊王'});// 可以直接存任意類型的數(shù)據(jù)
index2.js
wx.getStorageSync('data');// 獲取
應(yīng)用全局變量
不同的頁面都是處于一個共同的應(yīng)用當中的,這個應(yīng)用可以理解為 app.js
app.js
在這里可以定義公共數(shù)據(jù)
App({ myData: { name: "悟空" } })
index1.js
頁面中可以通過 getApp
]
??? ?? EventChannel wx.navigateTo
- ?? ????
this.getOpenerEventChannel()? ?? ? ? ????. </ code> ???? ???? <code>EventChannel
??? ?????. wx.navigateTo
?success
???? ???? ????. ??> EventChannel ??.
EventChannel
??? emit
? on
???? ???? ?? ???? ??? ??? ? ????. . index1.wxml
r
let app = getApp(); console.log(app.myData);index1.js
r
let app = getApp(); app.myData.name="八戒";index2.js??
const data = { name: "海賊王" }; module.exports = data;??????local stac ?????? ??? ?? ?? ?? ??????index1.js????
const data = require("../../common"); Page({ onLoad: function () { console.log(data); }, })????index2.js????rrreee??????Apply ?? ???????????? ???? ?? ??????? ???? ? ??????? ??? ? ??
app.js
??????app.js??????? ?? ?? ???? ???? ??? ? ??????rrreee????index1.js?????? ???? getApp
? ?? ?? ? ???? ?? rrreee???? ??rrreee???????? ??????????? ?? ???? ???? js ??? ??? ???? ? ?? ???? ??? ?? ????. ??????common.js????rrreee????index1. js???? rrreee??? ?? ????? ?? ??? ??? ??????? ?????? ?????! ! ??? ??? ?? ????? ?? ??? ???? ?? ??? ?? ???? ?????.? ?? ?????. ??? ??? PHP ??? ????? ?? ?? ??? ?????!

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

??? ??? ??? ????? ???? ?? WeChat? ???? ?? ???? ?? ??????? ?????. WeChat ?? ????? ???? ???? ??????? ?????? ???? ??? ?? ????? ?? ???? ? ?? ??? ?? ??? ??? ? ????. ? ????? Python? ???? WeChat ???? ???? ??? ?????. 1. ?? Python? ???? WeChat ???? ???? ?? ?? Python ?????? ???? ???. ???? wxpy? itchat ? ?????? ???? ?? ????. wxpy? ?? ?????

WeChat ?? ?????? ?? ??? ?? ?? WeChat ?? ?????? ?? ??? ??? ???? ?? ??? ??? ????? ?? ??? ??? ???? ? ?? ???? ????? ?????. ??? WeChat ????? ?? ??? ??? ???? ??? ??? ???? ?? ?? ??? ?????. ??, ?? ????? ??? ???? ??? ? ?? ?? ??? ???? ???. ??? ?? ??? ???? ?? ??? ?? ??? ?? ??? ???? ?? ????. <--index.wxml- ->&l

10? 31? ? ???? ??? ??? ?? 5? 27? Ant Group? '?? ?? ????'? ????? ????? ?? ??? ??? ?????. Alipay? '?? ?? - ??? ?? ??' ?? ????? ??????. ?? ???? ?? ??? ?????? ???? ?? ???? ?? ??? ?? ??? ???? Alipay? ?? ??? ?? ??? ???? ? ??? ???. ?? ???? "????", "????" ?? ???? ???? "????" ???? ??? ? ????. ?? ?????? ???? ????? ?? ? ???? ?? ?? ??? ??? ??? ? ??? ?? ? Alipay ????? ?? ?????? ?? ??? ?????. ? ??????? ?? ??????? ?? ?? ?? ?? ??? ??? ? ??? ?????. ? ?? ??? ??? ???? ?? ??? ?? ???????. ??? ??

?? ????? ??? ??? ? ????. ?? ??: 1. "react-reconciler"? ???? ???? ???? DSL? ?????. 2. DSL? ?? ???? ????? ?? ?? ???? ?? ??? ????. 3. npm? ???? ???? ?????. ???? npm? ?????. 4. ??? ???? ???? ??? ?? API? ???? ??? ?????.

???? ?? ????? H5 ??? ??? ????? ???? ?? ??? ?????. ?? ??? ???? ??? ????? ???? ?? ?? ????? H5? ?? ?????? ??? ?????. ??? ??? ?? ?????? uniapp? ?? ??? ???? ?? ????? H5 ?? ??? ???? ???? ?? ???? ?? ???? ? ????. ? ????? uniapp? ?? ????? H5 ?? ??? ??? ???? ??? ???? ???? ?? ??? ?????. 1. ??? ??? ??

?? ?? ?? ?? ????? ??? ? ?? ??? ?? ????, ?? ?????? ?? ?? ??? ???? ???? ??? ?? ???????.

?? ???? x01 ?? ?? ??, ?? ???? ??? ???? ???? ?????. ?? ??? ??? ??? ? ???? ?? ??? ?? ? ??? ?????. ?? ???? ???? ???? ??? ?? ??? ?????. x02 ?????? ??? ???? ?? ?????. ?????? ??? ???? ??? ?? ???? ?? ??? ???? ?????. ??? ??? ??? ????? ????? ??? ? ?? ???? ???? ???. ??? ??? ?? ???? ?? ??? ??? ?? ?????. ????, ??

PHP ? ?? ????? ??? ?? ?? ? ?? ?? ??? ?? ?? ? ?? ??? ?? ???? ??? ?? ? ??? ?????. ??? ??? ??? ?? ?? ?? ? ?? ??? ?? ???? ??? ???? ????. ?? ???? PHP? ???? ? ?? ???? ?? ?????. ? ????? PHP ? ?? ?????? ??? ?? ?? ? ?? ?? ?? ??? ???? ?? ?? ??? ?????. 1. PHP? ???? PHP??? ?? ????? ??? ? ????.
