The requested module '/node_modules/.vite/vue.js?v=65afd58f' does not provide an export na

出现这个问题,那么很有可能还是按照vue2的方式使用的Vue Router,建议先去了解下Vue Router 3

解决问题示例代码如下:

//router.js
import * as vueRouter from "vue-router";
import Home from "../views/Home.vue";

const routes = [
  {
    path: "/index",
    name: "Home",
    component: Home
  }
];

const router = vueRouter.createRouter({
  history: vueRouter.createWebHistory(),
  routes: routes
});
export default router;

或者:

//router.js
import {createRouter,createWebHistory} from "vue-router";
import Home from "../views/Home.vue";

const routes = [
  {
    path: "/index",
    name: "Home",
    component: Home
  }
];

const router = createRouter({
  history: createWebHistory(),
  routes: routes
});
export default router;
//main.js
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
createApp(App).use(router).mount('#app')

如上,vue3跟vue2的区别还是蛮大的,所以使用之前建议还是先去了解下vue3与vue2的区别。

上一篇:Eclipse中启动tomcat报错java.lang.OutOfMemoryError: PermGen space的解决方法


下一篇:Fibratus:一款功能强大的Windows内核漏洞利用和跟踪工具