未捕获语法错误:请求的模块'/node_modules/.vite/vue.js?v=535663ae'未提供名为'Default'的导出

Uncaught SyntaxError: The requested module #39;/node_modules/.vite/vue.js?v=535663ae#39; does not provide an export named #39;default#39;(未捕获语法错误:请求的模块#39;/node_modules/.vite/vue.js?v=535663ae#39;未提供名为#39;Default#39;的导出)

本文介绍了未捕获语法错误:请求的模块'/node_modules/.vite/vue.js?v=535663ae'未提供名为'Default'的导出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是名为griptape的js框架(用于区块链)。尝试使用VUE路由器时出现此错误。

import Vue from "vue"; //Error **does not provide an export named 'default'**
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    component: Home,
  },
  {
    path: "/about",
    name: "About",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/About.vue"),
  },
];

 const router = new VueRouter({
  routes,
});
export default router;

而我的vue.d.ts文件如下

import { CompilerOptions } from '@vue/compiler-dom';
import { RenderFunction } from '@vue/runtime-dom';

export declare function compile(template: string | HTMLElement, options?: CompilerOptions): RenderFunction;

export * from "@vue/runtime-dom";

export { }

router.d.ts文件如下

推荐答案

我认为您正在使用Vue 3。您应该检查您的vue-router版本。如果您现在只运行npm i vue-router,则版本应为";^3.5.3";。请尝试使用npm i vue-router@next安装较新版本。

然后按如下方式导出路由器:

import {createRouter, createWebHistory}  from 'vue-router'

const routes = [
    {
        path:'/',
        name:"Home",
        component:()=>import('./pages/Home.vue')
    }
    ,
    {
        path:'/about',
        name:"About",
        component:()=>import('./pages/About.vue')
    }
]

const router = createRouter({
    history:createWebHistory(),
    routes
})

export default router

这篇关于未捕获语法错误:请求的模块'/node_modules/.vite/vue.js?v=535663ae'未提供名为'Default'的导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:未捕获语法错误:请求的模块'/node_modules/.vite/vue.js?v=535663ae'未提供名为'Default'的导出

基础教程推荐