跳出foreach循环

直接return false没用,需要用throw来跳出foreach

 1       try {
 2         this.categoryList.forEach((item, index) => {
 3           if (item.title !== '') {
 4             data = {
 5               page: item.xxx,
 6               state: item.xxx,
 7             }
 8             throw new Error('')
 9           }
10         })
11       } catch (e) {
12         this.getList(data)
13         return false
14       }

 

posted @ 2020-03-31 16:14  谁凭花解语  阅读(913)  评论(0编辑  收藏  举报