![](https://img-blog.csdnimg.cn/cd995b29425f42f1a58d4972f4aed41c.png)
![](https://img-blog.csdnimg.cn/2deeebc53290449890cd90a8922f3866.png)
![](https://img-blog.csdnimg.cn/7df9ad5ebc094c47816dcd69e664e558.png)
1, 按照官方文档我们需要引入VueRouter,但是会报错 大致翻译为:请求的模块/node_modules/.vite/deps/vue-router.js?V =569ce1cd'没有提供名为'default'的导出
因为vue底层代码,导出的时候,使用 export xxx的形式暴露的
所以应该写为:以下形式
![](https://img-blog.csdnimg.cn/1979c597146f4107bf915803c68fdc75.png)
import {createRouter,createWebHashHistory} from 'vue-router';
import RigesCom from '../pages/RigesCom.vue';
import Music from '../pages/Music.vue';
const routes = [
{ path: '/', component: RigesCom },
{ path: '/music', component: Music },
]
const router = createRouter({
// 4. 内部提供了 history 模式的实现。为了简单起见,我们在这里使用 hash 模式。
history:createWebHashHistory(),
routes, // `routes: routes` 的缩写
})
export default router