这个是 vue3.0x 的写法
// 在最顶部引入createWebHistory
import { createRouter, createWebHistory, } from 'vue-router'
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
{ .... }
]
const router = createRouter({
history: createWebHistory(), // 在调用 createWebHistory() 即可
routes
})
然后 vue2.0.x 的写法
// vue2.0.x 写法比较简单
import VueRouter from 'vue-router'
const router = new VueRouter({
mode: "history",
routes
})