【问题标题】:Expected identifier but found "const" [closed]预期的标识符,但发现 \"const\" [关闭]
【发布时间】:2022-08-16 21:52:18
【问题描述】:

我试图导出 vue 路由器,但出现以下错误:

我的代码如下:

import { createRouter, createWebHistory } from \"vue-router\";
import HomeView from \"../views/HomeView.vue\";

const routes = [
    {
      path: \"/\",
      name: \"home\",
      component: HomeView,
    },
  ],

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes,
});

export default router;
  • ; 结束routes 声明,而不是,

标签: vue.js


【解决方案1】:

您应该在 cons routes = [ ... ] 之后删除逗号

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-23
    相关资源
    最近更新 更多