Skip to content

vue设置路径别名

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

json
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.

最近更新:10/11/2024, 5:04:42 AM

原文链接:vue设置路径别名

|下一篇:Java字符串相关类的底层原理