Mini Program jumps from the list page to the details page, how the details page gets all the data through id.

id from the list page

detail:function (event) {

var id=event.currentTarget.dataset.id
wx.navigateTo({
  url: "detail/detail?id="+id,
});

}

how do I get it on the details page?
data simulated by the interface using easymock

Jul.19,2021

print the options of the onLoad parameter of the details page.


solve

  • Product details page code is as follows
// 
onLoad(e) {
  // 
  console.log(e);
  // id
  const id = e.id; // url,
  // ...ajax
}

principle

  • is the parameter passed by query
  • Of course,
  • can also be operated by saving to a global variable and saving it to a local cache (when too many parameters are passed, or when objects need to be passed)

reference

https://developers.weixin.qq.

Menu