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

The console in the vue3 project reported this error
reason: history is not defined in the router file

Solution:

Modify the following codes:

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

to:

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

Read More: