Uncaught Error: Provide the “history“ option when calling “createRouter()“

vue3项目中控制台报了这个错误
原因:在router文件里面没有定义history

import {
    
     createRouter } from 'vue-router';
const router = createRouter({
    
    
    routes,
});

改为

import {
    
     createRouter , createWebHashHistory } from 'vue-router';
const router = createRouter({
    
    
    history:createWebHashHistory(),
    routes
})

猜你喜欢

转载自blog.csdn.net/weixin_42821697/article/details/124603234
今日推荐