In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to use foreach traversal array in Vue" related knowledge, editor through the actual case to show you the operation process, the method of operation is simple and fast, practical, I hope that this "how to use foreach traversal array in Vue" article can help you solve the problem.
Traversing the array in js
/ / define the shift detail array var bcglxiangxiList = new Array (); / / define the shift detail object var bcxiangxi = {}; / / the parameter bcglXiangXiListParam.forEach passed in the loop (element = > {bcxiangxi.xh = element.xh; bcxiangxi.bcbh = data.bcbh; bcxiangxi.dkkssj = element.sjfw [0]; bcxiangxi.dkjssj = element.sjfw [1]; bcxiangxi.ts = element.ts; bcxiangxi.dkdd = element.dkdd Bcxiangxi.zxjxljsj = element.jxsjfw [0]; bcxiangxi.zdjxljsj = element.jxsjfw [1]; / / Save the shift detail object into the shift detail array bcglxiangxiList.push (bcxiangxi);})
Traversing the array in vue
Var bcglxiangxiList = new Array (); var bcxiangxi = {}; debugger; if (response.data.bcglXiangXiList! = null & & response.data.bcglXiangXiList.length > 0) {console.log (response.data.bcglXiangXiList); response.data.bcglXiangXiList.forEach ((item, index) = > {console.log (item); bcxiangxi.xh = item.xh Bcxiangxi.bcbh = item.bcbh; / / debugger bcxiangxi.sjfw = new Array (); bcxiangxi.sjfw [0] = item.dkkssj; bcxiangxi.sjfw [1] = item.dkjssj; bcxiangxi.ts = item.ts; bcxiangxi.dkdd = item.dkdd; bcxiangxi.jxsjfw = new Array (); bcxiangxi.jxsjfw [0] = item.zxjxljsj Bcxiangxi.jxsjfw [1] = item.zdjxljsj; bcglxiangxiList.push (bcxiangxi);};}
You can see that the traversal method is the same, and it can also be traversed with two parameters in js.
/ / define shift detail array var bcglxiangxiList = new Array (); / / define shift detail object var bcxiangxi = {}; / / parameters passed in the loop bcglXiangXiListParam.forEach ((element,index) = > {bcxiangxi.xh = element.xh; bcxiangxi.bcbh = data.bcbh; bcxiangxi.dkkssj = element.sjfw [0]; bcxiangxi.dkjssj = element.sjfw [1]; bcxiangxi.ts = element.ts; bcxiangxi.dkdd = element.dkdd Bcxiangxi.zxjxljsj = element.jxsjfw [0]; bcxiangxi.zdjxljsj = element.jxsjfw [1]; / / Save the shift detail object into the shift detail array bcglxiangxiList.push (bcxiangxi);}) Vue forEach cycle uses / / data for the collection data.forEach (function (item, index) {/ / item is the index of the loop to which the object / / index is the loop, starting from 0}) this is the end of the introduction on "how to use foreach in Vue to traverse the array". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.