When building the vue3.0 project, there are still many changes in the configuration of routing.
When I encountered this error, I didn’t find it for a long time. Finally, I found out that when defining the routing mode, the
previous method wasmode
defined by attributes, vue3. x abolishedmode
the use insteadhistory
, and fromvue-router
the corresponding mode api implementation,
createWebHistory -> history
It corresponds to the history mode of the vue2.x version
import {
createRouter, createWebHistory } from "vue-router";
import Layout from "@/pages/Layout.vue";
const routes = [
{
path: '/',
component: Layout
}
]
const router = createRouter({
history: createWebHistory(),//这是正确的;错误提示:不要当成变量使用
routes
})
export default router