【发布时间】:2021-08-21 22:34:50
【问题描述】:
我正在尝试从本地 JSON 文件中读取数据,该文件存储了我的应用程序的一些配置数据。使用 ng build command in the Angular CLI 时不断出现错误。
我的组件的 TypeScript 文件:my-component.ts
...
import credentials from './config/credentials.json';
export class MyComponent implements OnInit {
...
// Properties
username: string = credentials.username;
...
}
JSON 配置文件,存储在“/config”位置:credentials.json
{
"credentials" : {
"username" : "my_user_name",
...
}
}
我收到错误消息:Error: Should not import the named export 'credentials' (imported as 'credentials') from default-exporting module (only default export is available soon)
是什么导致了这个错误?好像和issue described here很像。
【问题讨论】:
标签: javascript json angular typescript