The problem solved when the applet does not render the page after the data is modified.
Solve the problem that the page is not rendered after the data is modified by the Applet
Preface:
I have been optimistic about and maintain a certain degree of attention since the beginning of my application last year, I think it was my first time to consciously witness the development of a new technology in front-end and other technical development groups.
Sing down the applet? My opinion is certainly not possible, because the number of small programs that submit for review every day is still increasing, and some small programs are really useful, such as mobai's code scanning and cycling, in addition, I went to KTV last week and directly scanned the QR code on the screen with a small program to bind the room. Then, I clicked songs, cut songs, and made table packages to facilitate fun things, in my opinion, some application scenarios are very suitable for small programs. In the future, more scenarios will be used for more small programs.
Up to now, I have written more than a dozen articles in the mini-program series, basically solving some problems in development and hitting the pitfalls. My applet has already been written almost, but the company's https encryption authentication has not been completed, so it can only be put on hold for now.
Invalid Data Modification
We will continue to discuss a setData () issue today.
We often write as follows:
var that = this;wx.getStorage({ key: 'user', success: function(res){ console.log(res.data) that.data.params.uuid = res.data.uuid; that.data.params.ticket = res.data.ticket; that.data.params.courseUuid = options.courseUuid; that.data.params.isCompany = options.isCompany; that.fetchData(); that.getShareList(); }})
We assigned values to the data object, but we found that the data was not correct when we continued to use the data. The assigned data was not successfully rendered to the page. After looking for a long time, I found that to immediately validate data, you must call the setData () method to make it useful. Therefore, the above Code is modified as follows:
var that = this;wx.getStorage({ key: 'user', success: function(res){ console.log(res.data) that.data.params.uuid = res.data.uuid; that.data.params.ticket = res.data.ticket; that.data.params.courseUuid = options.courseUuid; that.data.params.isCompany = options.isCompany; that.setData({ params: that.data.params }) that.fetchData(); that.getShareList(); }})
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!