参照したページ
- [Solved] Uncaught Error: Provide the “history“ option when calling “createRouter()“ | ProgrammerAH
- javascript - Failed to resolve component <router-view> VueRouter - Stack Overflow
概要
vue-router を使っているアプリケーションを移行する際に発生するエラーです。
ブラウザのコンソールに出力されたエラー
Error: Provide the "history" option when calling "createRouter()"
解決方法
以下のように createRouter している箇所を
import { createRouter } from 'vue-router'; const router = createRouter({ routes, });
以下のように変更しました。
import { createRouter , createWebHashHistory } from 'vue-router'; const router = createRouter({ history:createWebHashHistory(), routes })
参照した2ページはそれぞれ、以下のメソッドを使用しています。
- createWebHashHistory
- createWebHistory
違いを調べてご自身のアプリケーションに適した方を使用してください。