How to solve the problem that the WeChat applet encounters a problem where the page does not render after modifying data

不言
Release: 2018-06-22 17:35:31
Original
3503 people have browsed it

This article mainly introduces relevant information on how to solve the problem of the page not rendering after the WeChat applet encounters modified data. Friends in need can refer to the following

After the WeChat applet encounters modified data Solving the problem of page not rendering

Foreword:

From the beginning of the mini program last year to now, I have always been optimistic and maintained a certain degree of attention. , I think the wave of small programs was initially among the front-end and other technology developers. This is the first time I have consciously witnessed the development of a new technology, and I feel quite honored.
Badmouthing mini programs? My point of view is that it is definitely impossible, because the number of small programs submitted for review every day continues to increase, and some small programs are really easy to use, such as Mobike’s QR code scanning and cycling, and I went to KTV last week and used the small program directly. The program scans the QR code on the screen to bind the room, and then use the mini program to request songs, cut songs, send emoticons and other convenient and fun things. Therefore, in my opinion, some application scenarios are very suitable for mini programs. , more mini programs will be used in more scenarios in life in the future.

Up to now, I have written more than a dozen articles in the mini program series, which basically solve some problems and pitfalls in development. My small program has almost been written, but the company's https encryption authentication has not been completed yet, so I can only leave it there for the time being.

Data modification does not take effect

Today we will continue to introduce a problem with setData().

We often write like this:

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();
  }
})
Copy after login

We performed some assignment operations on the data object, but found that the data was then used It was wrong. The data we assigned was not successfully rendered to the page. After searching for a long time, I discovered that if you want the data to take effect immediately, you must call the setData() method to be useful, so 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();
  }
})
Copy after login

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

WeChat applet implements the verification function of simple input regular expressions

WeChat applet obtains mobile phone Network status method [source code attached]

The above is the detailed content of How to solve the problem that the WeChat applet encounters a problem where the page does not render after modifying data. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template