function - Uncaught TypeError:
问题描述
I'm working on a web app with Vue.js and I get this error when I set up my routing in my route.js file, I don't see where is the problem. Is there someone that can help with this issue thanks?
router.js?41cb:8 Uncaught TypeError: Object(...) is not a function
at eval (router.js?41cb:8)
at Module../src/router.js (app.js:1349)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at eval (main.js:11)
at Module../src/main.js (app.js:1337)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at Object.1 (app.js:1362)
at __webpack_require__ (app.js:849)
eval @ router.js?41cb:8
./src/router.js @ app.js:1349
__webpack_require__ @ app.js:849
Here is my code below.
import {createRouter, createWebHistory} from 'vue-router';
import MusicApp from './components/home/MusicApp.vue';
import PageNotFound from './components/PageNotFound.vue';
const router = createRouter({
history: createWebHistory(),
routes: [
{path: '/', redirect: '/home'},
{path: '/home', component: MusicApp},
{path: '/:notFound(.*)', component: PageNotFound}
],
});
export default router;
解决方案
看起来您正在使用旧版本的 vue-router 和 Vue3。Vue3 仅适用于 alpha 版本。要安装 alpha 版本,请运行: npm install vue-router@next
推荐阅读
- node.js - 查询 AWS RDS PostgreSQL 数据库时 Firebase 函数超时
- docker - 是否可以从已使用的 Docker 容器创建新的 Docker 映像?
- java - 带有图像的请求中的管道损坏(写入失败)网关 x 服务
- c# - 在 Unity 中存储只读数据的良好做法
- mysql - MySQL DATE_ADD 语句根据书但不会返回结果
- excel - 从 Windows 文件夹读取的 Outlook 消息对于某些值是空白的
- sql-server - 如何在未透视表中创建计算行?
- mongodb - Mongodb:按id过滤父级时增加嵌套数组中的值
- algorithm - RSA加密后用户如何访问他的任何消息?
- ms-access - 仅在列表表单中显示每个员工的最新条目