在学vue用router调用beforeEach()更改组件的title时显示这个错误:
在这里插入图片描述
表达的意思是未定义router,这是因为在webstorm在生成脚手架时
router文件夹下index.js文件中的默认生成export default new Router({})导致没有router这个对象 而这个函数只能通过router调用
于是将脚手架默认生router文件夹下index.js文件中的export default new Router({})改为const router = new Router({}} 在其后加上export default router就可运用router.beforeEach()调用该函数了

Logo

基于 Vue 的企业级 UI 组件库和中后台系统解决方案,为数万开发者服务。

更多推荐