1
0

vue设置路径别名

2024-02-29
2024-10-11
文章摘要
|

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.

支持与分享

如果这篇文章对你有帮助,欢迎分享给更多人或者给予支持!