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
}