Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uni-app vue3 配置resolve.alias不生效问题 #5281

Open
Ba2Pp1S opened this issue Jan 7, 2025 · 0 comments
Open

uni-app vue3 配置resolve.alias不生效问题 #5281

Ba2Pp1S opened this issue Jan 7, 2025 · 0 comments

Comments

@Ba2Pp1S
Copy link

Ba2Pp1S commented Jan 7, 2025

首先我是通过Hbuilder X 创建的uni-app 默认模版 vue3 的项目
86a7392181c0d2787f50c12a07b24916

我现在需要设置路径的别名,我在项目根目录下新建了一个vite.confg.js文件,内容如下:

import {defineConfig} from "vite";
import uni from "@dcloudio/vite-plugin-uni";
import {resolve} from "path";

export default defineConfig({
    plugins: [
        uni(),
    ],
    resolve: {
        // 路径别名
        alias: {
            "@": resolve(__dirname, "./src"),
        },
    },
});

然后我又在根目录下新增了一个jsconfig.json文件,代码如下:

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  },
  "exclude": ["node_modules", "dist"]
}

当我使用@/引入路径时,运行不起来,地址错误。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant