The usage of the setData applet is described in detail.
How to Use the setData Applet
Recently, the following problems were encountered when using the setData of the applet. As follows:
When setData () is used to set attributes of an element of an array object, the official website uses the following code:
Page ({data: {array: [{text: 'init data'}] ,}, changeItemInArray: function () {this. setData ({'array [0]. text ': 'changed data '})}})
The value 'array [0]. text': 'changed data' is used. However, in actual use, we set an element in the array dynamically. That is, we usually should be 'array ['+ index +']. text': 'changed data', where index should be a dynamic number. But obviously, this is not available in the key of the object.
Therefore, I can only use a work und. As follows:
Var param = {}; var string = "array [" + index + "]. text; param [string] = 'changed data'; that. setData (param );
That is, prepare the object in advance.
I hope there will be better methods in the future.
Thank you for reading this article. I hope it will help you. Thank you for your support for this site!