小程序攜帶參數(單個或多個)跳轉頁面(實例)
阿新 • • 發佈:2019-03-29
-i con -name func tar pre ons 是你 傳遞數據
小程序html部分
data為傳遞至js的變量 name和id為變量名
<button class="an" data-name="鈞一" data-id="888" bindtap="tz">點我跳轉</button>
js部分
e是接收到的參數,打印e.currentTarget.dataset即可看見你所傳遞的變量
tz: function (e) { console.log(e) wx.navigateTo({ url: "../jy/jy?id= " + e.currentTarget.dataset.id + "&name=" + e.currentTarget.dataset.name,//傳遞多個變量
//url: "../jy/jy?id= " + e.currentTarget.dataset.id//傳遞單個變量
//url: "../jy/jy?id=333"//直接傳遞數據
})
}
jy頁面
在js裏找到
onLoad: function (options) { //options則裏就是你傳遞過來的變量 console.log(options) }
小程序攜帶參數(單個或多個)跳轉頁面(實例)