我想使用 tailwind 来做我所有的样式,并且不想在我的代码中添加额外的库。
这是我想出的一个简单示例:
我所做的:
创建了一个简单的组件,里面有一个基本的输入字段。Angular 似乎编译得很好,但 formly 似乎没有显示任何字段。它与Error: [Formly Error] There is no type by the name of "input"
.
我似乎也无法在没有主题的文档中找到任何示例。
我想使用 tailwind 来做我所有的样式,并且不想在我的代码中添加额外的库。
这是我想出的一个简单示例:
我所做的:
创建了一个简单的组件,里面有一个基本的输入字段。Angular 似乎编译得很好,但 formly 似乎没有显示任何字段。它与Error: [Formly Error] There is no type by the name of "input"
.
我似乎也无法在没有主题的文档中找到任何示例。
正式提供一组开箱即用的主题,例如材料,引导程序..但这不会阻止您创建自己的主题,唯一需要的步骤是定义自定义字段类型,如https://formly.dev/guide中所述/custom-formly-field 在这里总结的步骤是:
input
:import { Component } from '@angular/core';
import { FieldType } from '@ngx-formly/core';
@Component({
selector: 'formly-datetimepicker',
template: `
<input [formControl]="formControl"></input>
`,
})
export class InputFieldType extends FieldType {}
NgModule
通过声明定义您的字段类型:@NgModule({
declarations: [InputFieldType],
imports: [
....
FormlyModule.forRoot({
types: [
{ name: 'input', component: InputFieldType },
],
}),
],
})
export class AppModule {}
type
在您的字段配置中设置类型:fields = [
{
key: 'name',
type: 'input',
},
]
仍然困惑检查 Formly UI 源代码https://github.com/ngx-formly/ngx-formly/tree/master/src/ui