侧边栏壁纸
  • 累计撰写 116 篇文章
  • 累计创建 1 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

vue设置路径别名

vue设置路径别名

vite中添加下列高亮代码行的配置 vite.config.js/vite.config.js:

import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import topLevelAwait from "vite-plugin-top-level-await";
import { fileURLToPath, URL } from "node:url";

export default defineConfig({
    resolve: {
        alias: {
            "@": fileURLToPath(new URL("./src", import.meta.url)),
        },
    }
});

webpack类似。
附:vue+ts的可能会遇到报错Vue: Cannot find module @/router/router.ts or its corresponding type declarations.

博主关闭了所有页面的评论