WeChat applets solve the problem of page not rendering after data modification.

Source: Internet
Author: User

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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.