使用 Angular 4.1.1 启用 strictNullChecks
后,null
检查出现几个错误。我已经修复了它们的 bundle ,但无法为 this.form.get('username').value
修复相同的 Object is possibly 'null'
。与其他人一样,我也尝试过相同但无法修复错误。
if (this.form.get('username') != null) {
body.append('username', this.form.get('username').value);
}
最佳答案
尝试使用 Non-null assertion operator喜欢
this.form.get('username')!.value; // notice !
关于angular - TypeScript strictNullChecks - 对象可能是 'null',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43800907/