WeChat small program dynamically modified page data and parameter transfer process detailed

In the applet, we often need to dynamically render data. For newcomers, we often encounter a modified data in the console display and page display inconsistency, because we use “=” to modify the data, this is modified, However, it is not possible to change the state of the page, and the data is inconsistent, the code is as follows:

  Data: {Array: [{TEXT: 'array'}]} ONLOAD: Function () {this.data.Array [0] .text = 1; console.log (this.Data.Array [0] .text);}  

微信小程序 动态修改页面数据及参数传递过程详解

Modified code:

  ONLOAD: function () {// this.data.Array [0] .text = 1; this .SetData ({'Array [0] .text': '1'}) console.log (this.Data.Array [0] .text);}  

微信小程序 动态修改页面数据及参数传递过程详解

Summary: Data modified DATA has two methods

1, directly assigning the value, this is modified, but cannot change the page In the state, the data is inconsistent.

2, this.setdata, the setData function is used to send data from the logical layer to the view layer (asynchronous) while changing the value of the corresponding this.data (synchronization).

The above is all the content of this article, I hope to help everyone, I hope everyone will support Tumi Cloud.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment