gpt4 book ai didi

vue.js - 在 'default' 中找不到导出 'vue'(作为 Vue 导入)

转载 作者:行者123 更新时间:2023-12-03 23:44:07 26 4
gpt4 key购买 nike

我是这个 vue 的新手,当我尝试运行时出现此错误(npm run serve):

***WARNING Compiled with 4 warnings
warning in ./src/main.js
"export 'default' (imported as 'Vue') was not found in 'vue'
warning in ./src/main.js
"export 'default' (imported as 'Vue') was not found in 'vue'
warning in ./src/main.js
"export 'default' (imported as 'Vue') was not found in 'vue'
warning in ./src/router/index.js
"export 'default' (imported as 'Vue') was not found in 'vue'
应用程序运行于:
  • 本地:http://localhost:8080/
  • 网络:http://10.2.220.30:8080/** *

  • 索引.js
    import Vue from "vue";
    import VueRouter from "vue-router";
    import Home from "../views/Home.vue";
    Vue.use(VueRouter);
    const routes = [{
    path: "/home",
    name: "home",
    component: Home,
    meta: {
    requiresAuth: true
    }
    },
    {
    path: "/",
    name: "login",
    component: () =>
    import ("../views/login.vue")
    },
    {
    path: "/register",
    name: "register",
    component: () =>
    import ("../views/register.vue")
    }
    ];
    const router = new VueRouter({
    mode: "history",
    base: process.env.BASE_URL,
    routes
    });
    router.beforeEach((to, from, next) => {
    if (to.matched.some(record => record.meta.requiresAuth)) {
    if (localStorage.getItem("jwt") == null) {
    next({
    path: "/"
    });
    } else {
    next();
    }
    } else {
    next();
    }
    });
    export default router;
    主文件
    import Vue from "vue";
    import App from "./App.vue";
    import router from "./router";
    import axios from "axios";
    import "bootstrap/dist/css/bootstrap.css";

    const base = axios.create({
    baseURL: "http://localhost:4000"
    });

    Vue.prototype.$http = base;
    Vue.config.productionTip = false;
    new Vue({
    router,
    render: h => h(App)
    }).$mount("#app");

    最佳答案

    Vue v3:

    import * as Vue from 'vue';
    import * as VueRouter from 'vue-router';

    const routes = [
    // TODO
    ];

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

    Vue.createApp(App).use(router).mount('#app');
    https://next.router.vuejs.org/guide/migration/index.html

    关于vue.js - 在 'default' 中找不到导出 'vue'(作为 Vue 导入),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64039363/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com