3
我刚开始学习Angular,但出现以下错误: 无法绑定到'disabled',因为它不是' t已知财产<button>
。 在互联网上搜索我只是发现了类似的错误,但它们与FormsModule没有导入的事实有关,似乎并不是我的情况。无法绑定到“禁用”,因为它不是“<button>”的已知属性
app.components.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
Button = false;
}
app.component.html
<div style="text-align:center">
<h1>
Welcome to {{title}}!!
</h1>
<button [Disabled]="!Button">Click me</button>
</div>
app.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent,
],
imports: [
BrowserModule,
FormsModule,
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
使用小写'Disabled'在'<按钮[禁用] = “!按钮”>点击我' –
你不能利用 '已禁用'。它必须是“禁用”的。 – hyrumcoop
谢谢@Maximus!这是问题,我不能相信我试图找到问题,它很简单:( –