建设部资质网站查询,网站排名优化培训,视频网站中滑动列表怎么做的,一手接单网ts 如何配置引入 json 文件 参考文档#xff1a; https://maxgadget.dev/article/how-to-import-a-json-file-in-typescript-a-comprehensive-guide 项目中有一个 .json 的文件是配置文件#xff0c;如何引入到 ts 项目中
配置 tsconfig.json 文件#xff0c;添加这两个
{…ts 如何配置引入 json 文件 参考文档 https://maxgadget.dev/article/how-to-import-a-json-file-in-typescript-a-comprehensive-guide 项目中有一个 .json 的文件是配置文件如何引入到 ts 项目中
配置 tsconfig.json 文件添加这两个
{compilerOptions: {resolveJsonModule: true, esModuleInterop: true, }
}它的注释是这样
{compilerOptions: {resolveJsonModule: true, /* Enable importing .json files. */esModuleInterop: true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables allowSyntheticDefaultImports for type compatibility. */}
}再直接引入就可以了
import configDatabase from ../config/configDatabase.json