在 ng build --prod am gettng 错误,属性 'email' 类型上不存在“对象”
on ng build --prod am gettng error,Property 'email' does not exist on type 'Object
在 login.component.ts 中声明 loginObj 如下
public loginObj: Object = {
email:'',
password:''
};
public registerObj: Object = {
email:'',
name:'',
password:''
};
HTML
<input placeholder="" type="text" [(ngModel)]="loginObj.email" autofocus="true" required>
<input placeholder="" type="text" [(ngModel)]="loginObj.password" autofocus="true" required>
错误是正确的 属性 不存在。您需要创建接口
export interface LoginObject {
email:string;
password:string;
}
adn 然后将其导入您的组件并像这样声明您的对象
public loginObj: LoginObject = {
email:'',
password:''
};
你甚至可以尝试像这样声明它
public loginObj: LoginObject;
它会为你工作
将类型设为 any 而不是 Object 或定义接口并将其设为类型。
我在 jenkins 中构建它时遇到了类似的错误。以下命令解决了问题:
npm install
npm run ng build --prod
希望对您有所帮助
尝试在您的 package.json 中添加此依赖项
"@angular/compiler-cli":"9.0.0(或您使用的其他版本)"
在 login.component.ts 中声明 loginObj 如下
public loginObj: Object = {
email:'',
password:''
};
public registerObj: Object = {
email:'',
name:'',
password:''
};
HTML
<input placeholder="" type="text" [(ngModel)]="loginObj.email" autofocus="true" required>
<input placeholder="" type="text" [(ngModel)]="loginObj.password" autofocus="true" required>
错误是正确的 属性 不存在。您需要创建接口
export interface LoginObject {
email:string;
password:string;
}
adn 然后将其导入您的组件并像这样声明您的对象
public loginObj: LoginObject = {
email:'',
password:''
};
你甚至可以尝试像这样声明它
public loginObj: LoginObject;
它会为你工作
将类型设为 any 而不是 Object 或定义接口并将其设为类型。
我在 jenkins 中构建它时遇到了类似的错误。以下命令解决了问题:
npm install
npm run ng build --prod
希望对您有所帮助
尝试在您的 package.json 中添加此依赖项 "@angular/compiler-cli":"9.0.0(或您使用的其他版本)"