Home > front end >  Taro setState how to set up an item in the array
Taro setState how to set up an item in the array

Time:11-02

Use Taro development WeChat small programs, when setState, large amount of data of load time special long, to more than ten seconds, and then want to do a paging, but looking for half a day also can not find the update only one method, is used in the online said WeChat applet native
Data: {
//the current page
PageNo: 0,
//data source
List: []
},

GetListData: function () {
//the load data
Let _list=[];
.
SetData ({
[' list '[' + pageNo +]] : _list,
});
}
No matter use, also can't setState paging?

CodePudding user response:

Well, I don't know whether I understand you want to reach consensus
I understand your intention "paging", it is like this post, reply, there is page 2 and page 3,... N page
And before you is to get all the data and binding with the view, then, you now sleep caton time is too long, so want to let all of the data capture all later, in the view when binding data, then draw part data belong to this page, the corresponding data,

Is this mean?

If it is:
Data-driven model, to render the structure of the dependent data source for the current complete data sources can, uh, a little round, that is to say, what do you mean by "paging", it should only take effect in the API request and returns the data, the view itself is not the so-called "paging" in principle, it shows that you get all the data from the API, and the "paging" is just the end user to see a "effects", has nothing to do with the view itself, it exists only in your API request data, as a condition for API returns the data corresponding to you,

Such as: the current view you bind "page 1" data, first you send the request to the API, indicated in the request, as long as it belongs to "page 1" data, then the API return "page 1" data you want to give you, you put the data directly with the view to binding

PM, drank a little more, may be a bit slow a bit of a mess, but if I understand what you say, yes, it probably is this meaning...
  • Related