Kar*_*erg 6 javascript visual-studio-code
我在 javascript 项目的根目录中添加了 ajsconfig.json来尝试排除一些构建文件以及设置一些路径映射,但似乎没有发生任何事情。部分问题是我不确定使用 a 时的预期结果是什么jsconfig.json,我已经阅读了它的文档,但它没有展示任何结果。
有人可以给我提供一个小而有效的jsconfig.json描述,说明它的实际用途吗?这样我就可以用它来验证它是否确实适用于我的项目。
或者,有人知道一种方法来验证jsconfig.jsonVS Code 是否正在工作/拾取吗?
小智 6
在我的项目中,我使用 jsconfig.json 文件来访问直接从我尝试导入的位置的 ./src 目录导入的文件。
我的 jsconfig.json 看起来像:
{
"compilerOptions": {
"baseUrl": "./src"
},
"include": [
"src"
]
}
Run Code Online (Sandbox Code Playgroud)
包括:
如果不存在 include 属性,则默认包含包含目录和子目录中的所有文件。当指定 include 属性时,仅包含这些文件
基本网址:
这给出了文件导入路径的基目录
这是我使用 jsconfig.json 的项目结构
所以如果我需要从src/util/auth_util.js内部导入一个函数src/component/Login/index.js
src/component/Login/index.js 里面
src/component/Login/index.js :
import { userLogin } from 'util/auth_util.js'
如果没有使用上面提到的 jsconfig.json 则导入语句
src/component/Login/index.js :
import { userLogin } from '../../util/auth_util.js'
| 归档时间: |
|
| 查看次数: |
8112 次 |
| 最近记录: |