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

2021/9/15 22:08:14

本文主要是介绍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的区别。



这篇关于The requested module '/node_modules/.vite/vue.js?v=65afd58f' does not provide an export na的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程