javascript - How to traverse the json data structure returned by the background if it is too deep?
某草草2017-05-19 10:18:40
0
3
692
How do I loop through the json data with this structure to get the deepest one, and I use the string splicing method. If I render below, I can only use a for loop. Is there any way to use a large for? Loop through the data? ? ? please help
I agree with the above, use js templates such as artTemplate and the like. If you insist on using string concatenation, it is a loop within a loop. It’s nothing more than adding a little syntactic sugar. As follows.
Complex answer: Each layer of Object uses a function to convert it into a string, and then splices it in the outermost layer.
A smarter approach: don’t use jQuery. If you need to be compatible with IE9-, use Knockout.js, avalon.js. If those old guys and ladies can be given up, use VueJS, Angular 4.0+, React. Then give them a hint: your browser is too old.
I agree with the above, use js templates such as artTemplate and the like.
If you insist on using string concatenation, it is a loop within a loop. It’s nothing more than adding a little syntactic sugar.
As follows.
The results are as follows
Simple answer: use functions.
Complex answer: Each layer of Object uses a function to convert it into a string, and then splices it in the outermost layer.
A smarter approach: don’t use jQuery. If you need to be compatible with IE9-, use Knockout.js, avalon.js. If those old guys and ladies can be given up, use VueJS, Angular 4.0+, React. Then give them a hint: your browser is too old.
In this case, it is recommended to use js template. It is too troublesome to splice the strings yourself