Url parsing applet parameters behind

Acquisition parameters jump

1, frequently used in the applet and click on the jump operation parameters need to pass e.g.

wx.navigateTo({
  url: '../payDetails/payDetails?activity_id=' + self.data.order_id + '&isfirst=' + self.data.isfirst,
})
These parameters are got to get in there ayDetails page onload
onLoad: function (options) {
  console.log(options)
}
This will get the corresponding parameter
2, scan code to enter the pass parameters in the applet method it is the same but the data is too much background in this area is to give my own stitching parameters and then parse the contents of the two-dimensional code is probably https: //www.***** . ** com / w p = scale & bmi = 24.3 & bmr = 1586 & bodyAge = 23 & bodyShape = 4 & bodyfat = 19.9 & bone = 2.82 & hasMeasured = true & heartIndex = 2.9 & heartRate = 73 & lbm = 56.3 & leftWeight = 0 & mac = D6:? 7F: A4: 42: DB: 74 & measureTime = Sep 21, 2019 15: 25: 09 & method = 4 & muscle = 45.6 & muscleMass = 53.5 & protein = 18.27 & resistance50 = 479 & resistance500 = 431 & resistanceState = 0 & score = 88.3 & subfat = 17.7 & trueResistance50 = 479 & trueResistance500 = 431 & visfat = 7 & water = 57.8 & weight = 70.3 & age = undefined & gender = male & height = 170 first, get the URL parameters we turn into a usable format 
Function converts a simple package array 
splitArr:function (arr) {
  var obj = {};
  for (var i = 0; i < arr.length; i++) {
    split = var arr [i] .split ( ':');
    obj[split[0]] = split[1];
  }
  return obj;
}
// q is the url address
let result = this.splitArr(q.split("?")[1].replace(/=/g,":").split('&'))
// results 
So to get the data we can use the fact, first convert the address into an array and then converted into an array of objects so that we can get the value corresponding to the key you have any good way to mention oh
 

Guess you like

Origin www.cnblogs.com/qq976864507/p/11770368.html