报错内容
main.js:13 [Vue Router warn]: Unexpected error when starting the router: TypeError: Cannot read properties of undefined (reading ‘pending’) at eval (index.js:45:1) at Array.forEach ()
bug修改
在 Vue.js 中使用 Vue Router 时遇到 "Unexpected error when starting the router: Typ"
这样的错误,通常是由于路由配置不正确或者某些依赖未正确安装或初始化引起的。
本次修改方法
查看图片报错,能确定为路由问题,修改路由为正常路由就好了。
//原错误路由
import { postPage, putEdit} from '@/api/tation/manage'
//正确路由
import { postPage, putEdit} from '@/api/powerStation/manage'
其他可能出现问题
- 检查路由配置
确保路由配置是正确的。这包括检查 routes 数组中的每个路由对象。
以下代码仅为参考,实际代码按照实际项目来。
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{
path: '/about',
name: 'About',
component: About
}
];
- 确保组件正确导入
确保你引用的组件已经正确导入。例如,如果你使用了 component: Home,你需要确保已经从相应的文件中导入了 Home 组件:
import Home from './components/Home.vue';
import About from './components/About.vue';
- 重新安装依赖
有时候,问题可能是由于依赖没有正确安装。尝试删除 node_modules 文件夹和 package-lock.json 或 yarn.lock 文件,然后重新运行 npm install 或 yarn 来重新安装依赖:
rm -rf node_modules package-lock.json yarn.lock
npm install # 或者 yarn install
您好,我是肥晨。
欢迎关注我获取前端学习资源,日常分享技术变革,生存法则;行业内幕,洞察先机。