在Angular Material 9中,您需要使用MatFormFieldModule和MatInputModule模块来正确导入表单控件。以下是一个包含MatInput的示例:
首先,确认您已经导入了“@angular/material”和“@angular/forms”依赖:
import { MatInputModule } from '@angular/material/input';
import { MatFormFieldModule } from '@angular/material/form-field';
@NgModule({
imports: [
MatFormFieldModule,
MatInputModule,
// other imports...
],
})
export class AppModule { }
接下来,在HTML模板中使用MatFormField和MatInput:
如果您仍然遇到UI问题,请确保您的Angular版本是9或更高,并查看控制台中的任何错误消息。如果问题仍然存在,请尝试查看官方文档或提交一个问题请求帮助。