1. When the navigator jumps
wxml page ("&" is available when there are many parameters)
1 |
|
Or add a click event, js uses navigateTo to jump and pass parameters, the two effects are the same
wx.navigateTo({ url: '../index/index?id=1&name=aaa', })
The js page is directly obtained in onLoad
onLoad: function (options) { //Page initialization options are parameters brought by page jump var id = options.id //Get value },
2. Global variables
app.js page
globalData:{ id:null }
assignment:
var app = getApp(); app.globalData.id = 2
Value:
var app = getApp(); var id = app.globalData.id
3. List index subscript value
wxml page
1 |
|
If you need to pass more than one, you can write multiple data-[parameters] to pass
js page
1 2 3 4 |
|
Note : Set data-[parameter name] to pass parameters through wxml, [parameter name] can only be lowercase, not uppercase
4. form form pass value
The value passing in the form form is relatively simple and commonly used, so I won’t give an example