forEach循环 当满足条件时跳出该循环
使用try catch
try {
this.menuData.forEach((item: any) => {
if ((toPath as string).indexOf(item.url) === 0) {
this.currentUrl = item.url
throw new Error ('EndIterative')
}
})
} catch (e) {
if (e.message !== 'EndIterative')
throw e
}
版权声明:本文为weixin_43452622原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。