静态解析符号值时遇到错误.调用函数"CreateCustomComponent",不支持函数调用 [英] Error encountered resolving symbol values statically. Calling function 'CreateCustomComponent', function calls are not supported

查看:112
本文介绍了静态解析符号值时遇到错误.调用函数"CreateCustomComponent",不支持函数调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建自定义组件时出现错误提示.

I am getting below error when creating my custom component.

在静态解析符号值时遇到错误.调用函数"CreateCustomComponent",不支持函数调用 d.考虑使用对导出函数的引用替换函数或lambda,以解决符号cus_input

Error encountered resolving symbol values statically. Calling function 'CreateCustomComponent', function calls are not supporte d. Consider replacing the function or lambda with a reference to an exported function, resolving symbol cus_input

我的文件如下.有人可以给我一个下面我的代码的答案吗?

my file like as below. Any one please give me a answer for below my code ?

export class MyComponent {   

constructor() {
   console.log("Component created");
}
}
export function CreateCustomComponent( componentArgs: {
selector: string,
inputs: Array<string>,
template: string 

 }): Type<any> {

let comp = Component(componentArgs);
return comp.Class({
    extends: MyComponent,
    constructor: []
});
}

export let cus_input :any = CreateCustomComponent({selector: 'cus-inp',inputs : ["myinput"],template : '<input [value]="myinput" />'})

export const MY_INP_Component: any = [cus_input];

如下所示在"app.modeule.ts"中导入

Importing like as below in "app.modeule.ts"

 import { MY_INP_Component} from './customcomponent/core';

 import { AppComponent } from './app.component';


 @NgModule({
    imports: [BrowserModule, FormsModule, HttpModule,       RouterModule.forRoot(rootRouterConfig, { useHash: true })],
    declarations: [AppComponent, 
     MY_INP_Component
   ],
  bootstrap: [AppComponent],

   })
export class AppModule { }

这就是为什么m动态创建组件意味着我为m动态创建组件并在jquery插件中使用这些组件输入和输出的一组jquery插件.

Here why m creating component dynamically means i have set of jquery plugins for that m creating component dynamically and using these component inputs and outputs in jquery plugin.

推荐答案

升级CLI版本后,我也遇到了这个问题.它与AOT编译器有关.

I had this problem too after upgrading my CLI version. It has something to do with the AOT compiler.

您可以通过以下方法解决此问题:将函数导出并包装到应用程序模块中的另一个函数(必须是应用程序模块)中,然后使用导出的函数,如下所示:

You can fix this by exporting and wrapping your function in another function in your app module (must be app module), and then using the exported function like so:

export function doCreateCustomComponent(){
  return CreateCustomComponent(...);
}

@NgModule({ ... 
declarations: [doCreateCustomComponent], 
bootstrap: [doCreateCustomComponent]
... })
export class AppModule { }

(我已经稍微简化了您的代码)

(I've simplified your code slightly)

这篇关于静态解析符号值时遇到错误.调用函数"CreateCustomComponent",不支持函数调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆