The content of this article is about code examples for dynamically obtaining list object information in small programs. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
First the renderings :
##This content Mainly introduces how to dynamically obtain object details in a list: 1. First display the list content:
The list content is still implemented through data binding and chat table rendering, a series of parameters of wx:for set up.
<block> <view> <!--界面跳转 --> <image></image> <text>{{item.pf_name}}</text> <!-- <text>{{item.pf_id}}</text> --> </view> </block>
goDetail, the object ID to jump to is item.pf_id, and the clicked object is index. Of course, this can also be set as a navigator jump. The difference is that the navigator adds a combination of parameters in the link and passes it to the page, which is suitable for hard-coded content.
2. In view of the dynamic acquisition, it is natural to request background data:
goDetail: function(ev) { var that = this; var e = ev.currentTarget.dataset.id; console.log("++++++",ev,that) wx.setStorageSync("people_id", e), wx.navigateTo({ url: "../detail/detail" }) },
id is stored as cache data and sent to the next page for acquisition. Be sure to print via console.log(" ",ev,that). To test whether the data is obtained or stored. The object details page can be displayed like this:
require("../../utils/util.js"), getApp(); Page({ data: { name: "", sex: "", birthday: "", post: "", address: "", addtime: "", phone: "", identityCard: "", schools: "", pspecialty: "", diploma: "", workingState: "", entrytime: "", worktime: "" }, onLoad: function(e) { var t = this, a = wx.getStorageSync("session_uid"), i = wx.getStorageSync("people_id"); console.log("--------",i,e,a) wx.request({ url: "https://xxxxxxxxxxxxx.com/wx/userinfo/", data: { pf_id: i, Cookie: a }, method: "POST", header: { "Content-Type": "application/x-www-form-urlencoded" }, success: function(e) { console.log("员工数据", e.data.data); var a = e.data.data; t.setData({ name: a.pf_name, sex: a.pf_sex, birthday: a.pf_birthday, post: a.m_id_post, address: a.pf_address, addtime: a.pf_addtime, phone: a.pf_phone, identityCard: a.pf_identityCard, schools: a.pf_schools, diploma: a.m_id_diploma, pspecialty: a.pf_specialty, workingState: a.pf_workingState.state_name, entrytime: a.pf_entrytime, worktime: a.worktime }) }, fail: function(e) {} }) }, onReady: function() {}, onShareAppMessage: function() {} });
Finally you can get the dynamic information of the object.
The above is the detailed content of Code example for dynamically obtaining list object information in a mini program. For more information, please follow other related articles on the PHP Chinese website!