我已经升级到最新的 angular cli,现在我得到这个错误:
Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol 'dictionary'. Consider exporting the symbol (position 12:7 in the original .ts file), resolving symbol TRANSLATION_PROVIDERS in C:/xampp/htdocs/milesofmusic/src/app/translate/translation.ts, resolving symbol AppModule in C:/xampp/htdocs/milesofmusic/src/app/app.module.ts, resolving symbol AppModule in C:/xampp/htdocs/milesofmusic/src/app/app.module.ts
它引用的代码是这样的:
// all traslations
const dictionary = {
[LANG_EN_NAME]: LANG_EN_TRANS,
[LANG_HE_NAME]: LANG_HE_TRANS,
};
// providers
export const TRANSLATION_PROVIDERS = [
{ provide: TRANSLATIONS, useValue: dictionary },
];
在我的应用程序模块中导入 从 './translate/translation' 导入 { TRANSLATION_PROVIDERS }; 并将它放在提供者数组中
如何解决?
最佳答案
const dictionary = {
[LANG_EN_NAME]: LANG_EN_TRANS,
[LANG_FR_NAME]: LANG_FR_TRANS,
};
我也遇到同样的错误,所以做一件事:直接写语言值而不是括号。
const dictionary = {
"en-US": LANG_EN_TRANS,
"fr-FR": LANG_FR_TRANS,
};
享受快乐编码
关于angular2 升级后静态解析符号值时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41831235/