​1、适用于 idea 2023.2.4+

原来是 idea 2023.2.1 ,突然发现 @/路径不能识别了,经确认 idea 自动升级到2023.2.4
参考[1]
解决 IDEA下VUE项目 @符号无法识别的问题 https://blog.csdn.net/weixin_44022996/article/details/134580063

vue项目下 新建jsconfig.json ,重启idea ,idea 自动扫码索引即可识别
或 File -> invalidate caches 然后点击 just restart

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

​2、适用于 idea 2023.2.1 -

idea 打开vue 不能识别@路径 https://blog.csdn.net/lmj3732018/article/details/123083479

第一步:

vue项目下自定义一个文件,如webpath.config.js,内容为:

'use script'
const path = require('path');
function resolve(dir) {
    return path.join(__dirname, dir);
}
module.exports = {
    resolve: {
        alias: {
            '@': resolve('src')
        }
    }
};

第二步:

File > Settings > Languages & Frameworks > JavaScript > Webpack

设置 webpack configuration file为webpath.config.js

第三步:

重启idea,解决

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐