加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular – decorator中不支持函数调用

发布时间:2020-12-17 07:22:16 所属栏目:安全 来源:网络整理
导读:我正在尝试使用-aot选项(ng build -aot)构建应用程序.我有以下错误: ERROR in Error during template compile of 'MyComponent' Function calls are not supported in decorators but 'classLogger' was called in 'cLog' 'cLog' calls 'classLogger'. 但是
我正在尝试使用-aot选项(ng build -aot)构建应用程序.我有以下错误:
ERROR in Error during template compile of 'MyComponent'
  Function calls are not supported in decorators but 'classLogger' was called in 'cLog'
    'cLog' calls 'classLogger'.

但是我需要这个调用,我不知道我应该如何更改代码以使其工作.

export function classLogger(_classOptions?) {
   const myLogger = new MyLogger();
   myLogger.options = Object.assign({},defaultClassOptions,_classOptions);

   return myLogger.loggerCB;
}

// export function clog(options = defaultClassOptions): Function {
export function cLog(options?): Function {
   return loggingEnabled ? classLogger(options) : emptyClassDecorator();
}

附:类装饰器接受必须转移到装饰器补丁回调的选项.

我也遇到过这个问题.在我的情况下,我想覆盖BusyConfig参数.应用程序适用于ng服务,但是当我想为生产构建应用程序时,修饰符不支持函数调用但是…发生异常.

我的解决方案如下:
ng build –prod –aot = false

The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML
and TypeScript code into efficient JavaScript code during the build
phase before the browser downloads and runs that code.

ng build –prod与ng build –prod –aot相同

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读