Directly upload the picture:
Requirements: Column headers and content are obtained from the returned data;
There is a problem now: when the query result is 7 items, the data can be displayed (as shown in the figure above); but when it is one When it comes to results, there is a problem with parsing;
Code:
The error message is as shown below:
Do you have any ideas?
In fact, the value obtained from the returned json data is used as the header information. Because the returned data format is the same, the content of the title is the same. We directly intercept the first array returned. The information is OK as the header.
You can put your
data1
indata()
as a local variable.The problem is that you changed the data. When your data changed from 7 to 1, your tableColumns still wrote 7. There is no data for day2 in your data. However, the tablecolumns still have not changed. At this time, the rendering Then I will look for the data of day2 and find day2undefinde. The correct method is to dynamically change the tableColumns based on the data in data1