【问题标题】:How to change function to export function for decorator?如何将功能更改为装饰器的导出功能?
【发布时间】:2020-10-17 22:28:21
【问题描述】:

我有一个 Angular 项目,我在 app.module.ts 中使用以下代码导入模块:

@NgModule({
 imports: [
   ...,
   NgxEchartsModule.forRoot({
     echarts: () => import('echarts')
   }),
 ],
})

但是当我尝试将项目构建为无服务器时,我得到以下关于上述导入的信息,并要求我将其更改为导出功能,以便它可以被 decarator 支持。我怎么做?我尝试了不同的导出方法,但它不起作用。

ERROR in src/app/app.module.ts(107,16): Error during template compile of 'ɵ0'
  Function expressions are not supported in decorators
    Consider changing the function expression into an exported function.

作为参考,我正在尝试将 ngx-echarts 导入 Angular 项目。 https://www.npmjs.com/package/ngx-echarts

感谢您的帮助。

【问题讨论】:

    标签: angular serverless-framework echarts


    【解决方案1】:

    以下内容对我有用:

    NgxEchartsModule.forRoot({ echarts })
    

    eChart exception (NgxEchartsDirective -> InjectionToken NGX_ECHARTS_CONFIG)

    【讨论】:

    • 我收到No value exists in scope for the shorthand property 'echarts'. Either declare one or provide an initializer.。有什么想法吗?
    • 试试这个:NgxEchartsModule.forRoot({ echarts: { init: echarts.init } })
    猜你喜欢
    • 2011-02-14
    • 2016-06-11
    • 2015-05-25
    • 1970-01-01
    • 2022-01-09
    • 2021-07-05
    • 2018-11-07
    • 2021-01-17
    • 2021-12-15
    相关资源
    最近更新 更多