试了N多方法没有解决,最后,在router的配置文件index.js中,把createWebHistory换成createWebHashHistory,解决了!
import {createRouter, createWebHistory,createWebHashHistory,useRouter} from 'vue-router'
const routes = [
{
path: '/',
name: 'home',
component: () => import('/src/view/Home.vue')
},
{
path: '/home',
name: 'home',
component: () => import('/src/view/Home.vue')
},
{
name: 'demo',
path: '/demo',
component: () => import('/src/view/Demo.vue')
},
{
name: 'edit',
path: '/edit:#:id:name',
component: () => import('/src/view/TimeEdit.vue')
},
{
path: '/:catchAll(.*)',
name: 'not-found',
component: () => import('/src/view/Home.vue')
}
];
const router = createRouter({
history: createWebHashHistory(),
// history: createWebHistory(),
routes
})
export default router