angular 开发 错误收集
2019-09-29 本文已影响0人
四月天__
1、Angular: Can't bind to 'ngModel' since it isn't a known property of 'input'
Can't bind to 'ngModel' since it isn't a known property of 'DatePickerView'
问题解决
刚学习使用angular,在使用[(ngModel)]做双向绑定时就遇到了上面的报错,折腾了半个小时,最后还是请教了度娘解决,
解决办法:
在你的app.module中添加如下代码即可:
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@NgModule({
imports: [
FormsModule //此代码仅为需加入的部分,注意比对你本身的代码,把这个加入其中即可
]
参考:https://blog.csdn.net/zhang__ao/article/details/80250283
2、npm ERR! Cannot read property 'match' of undefined 错误处理
删了项目文件夹下面的package-lock.json
,然后再运行npm install
便可正常的安装了~~~
如果还是不行运行下面命令试试
rm -rf node_modules
rm package-lock.json
npm cache clear --force
npm install
参考 : https://blog.csdn.net/Jane_96/article/details/81451759
3、Angular @ViewChild() error: Expected 2 arguments, but got 1
In Angular 8 , ViewChild takes 2 parameters
参考下面的写法即可
@ViewChild(ChildDirective, {static: false}) Component
参考:https://stackoverflow.com/questions/56704164/angular-viewchild-error-expected-2-arguments-but-got-1