首页 > 解决方案 > 在 Prod env 中将 isDevMode 传递给 forRoot 抛出错误

问题描述

代码如下

const isDev = isDevMode()
const modules = [
    HttpClientModule,
    NgxsModule.forRoot(AllStates, { developmentMode: isDev }),
]

此代码在开发环境中运行良好,但会在产品环境中引发错误。错误是Error during template compile of 'CoreModule' Function calls are not supported in decorators but 'isDevMode' was called.

有没有办法将 isDevMode 传递给 forRoot 函数?谢谢

标签: javascriptangularangular-cli

解决方案


最后,我使用const isDev = !environment.production,并且工作良好。


推荐阅读