uncaught typeerror: cannot use ‘in’ operator to search for ‘path’ in undefined问题解决
主要是问题在router.js 中个人代码不熟悉
import {createRouter,createWebHistory} from 'vue-router'
import loginVue from '@/views/login.vue'
import layoutVue from '@/views/layout.vue'
const routes = [
{path: '/login',component: loginVue},
// 默认是login
{path: '',redirect: '/login'},
{path: '/layout',component: layoutVue}
]
// 创建路由器
const router =createRouter({
history:createWebHistory(),
routes:routes
})
export default router
如果这里的代码没有加上括号,就会报错。
history:createWebHistory()//正确写法
history:createWebHistory//个人报错的写法