前端白名单过滤
router.beforeEach(((to, from, next) => { let white = ['/clogin', '/index', '/'] if (white.includes(to.path)) { next() } else { let vuelist = localStorage.getItem('vuelist') console.log(vuelist) if (vuelist) { let reslist = JSON.parse(vuelist) console.log(reslist) let reslist1 = [] for (let i in reslist) { console.log(i) reslist1.push(reslist[i]["url"]) } console.log(reslist1) if (reslist1.includes(to.path)) { next() } else { alert('没有权限') return false; } } } }))
浙公网安备 33010602011771号