Angular 无法读取属性';附表';未定义的
所需的输出是BsDatePicker,由于某种原因给了我一个错误:无法读取未定义的属性“schedule”Angular 无法读取属性';附表';未定义的,angular,angular5,web-frontend,ngx-bootstrap,Angular,Angular5,Web Frontend,Ngx Bootstrap,所需的输出是BsDatePicker,由于某种原因给了我一个错误:无法读取未定义的属性“schedule”,并且还有警告BsDatepickerModule正在开发中, 可能会发生重大变化, 请阅读变更日志 Angular CLI版本1.7.4,ngx引导版本3.0.0,Angular 5 这是html的代码: 这是app.module.ts的代码: 这是我的app-routing.module.ts 这是我的.angular cli.json ..."testTscon
,并且还有警告BsDatepickerModule正在开发中, 可能会发生重大变化, 请阅读变更日志
Angular CLI版本1.7.4,ngx引导版本3.0.0,Angular 5
这是html的代码:
这是app.module.ts的代码:
这是我的app-routing.module.ts
这是我的.angular cli.json
..."testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css",
"../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"styles.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.slim.min.js",
"../node_modules/popper.js/dist/umd/popper.min.js",
"../node_modules/bootstrap/dist/js/bootstrap.min.js"
],
"environmentSource": "environments/environment.ts",...
我认为ngx bootstrap 3.0.0不是一个稳定的版本。正如您在他们的文档站点中看到的那样。最新的稳定版本是2.0.5。 但当您尝试通过命令安装它时:
npm install ngx-bootstrap --save
此命令将尝试获取最新版本is 3.0.0。
所以,原因很简单,3.0.0版本目前并不稳定。选择最新的稳定版本2.0.5 以下步骤有效
rm -rf node_modules/ngx-bootstrap
package.json:“ngx引导”:“^3.0.0”
到“ngx引导”:“2.0.5”
我尝试了上述解决方案,效果很好 以下步骤: package.json:“ngx引导”:“^3.0.0”到“ngx引导”:“2.0.5” npm安装ngx引导程序
再次运行服务器:ng serve执行以下步骤,它将修复此问题:
Step 1: npm uninstall ngx-bootstrap
Step 2: npm install ngx-bootstrap@2.0.5 --save
Step 3: ng serve
Step 4: Add the css file path "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css" in styles array in angular-cli.json file
由于某些原因,3.0.0版不起作用,然后我尝试了2.0.5版,效果非常好!!!但我仍然想知道使BsDatepicker工作的解决方案,必须有一个解决方案!如果您不使用导致错误的命令,而是显示修复错误的命令,例如,
npm install ngx,那么这个答案会更好-bootstrap@2.0.5--保存
而不是使用rm,您可以转到npm卸载ngx引导
rm -rf node_modules/ngx-bootstrap
npm install ngx-bootstrap
Step 1: npm uninstall ngx-bootstrap
Step 2: npm install ngx-bootstrap@2.0.5 --save
Step 3: ng serve
Step 4: Add the css file path "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css" in styles array in angular-cli.json file