javascript - 未捕获的类型错误:core_1.style 不是函数
问题描述
我将代码从 Angular 4 转换为 Angular 7 并成功编译。但是当我尝试运行它时,在broser的控制台中它给出了以下错误。
Uncaught TypeError: core_1.style is not a function
at Object.<anonymous> (ng2-dropdown.bundle.js:435)
at __webpack_require__ (ng2-dropdown.bundle.js:30)
at Object.<anonymous> (ng2-dropdown.bundle.js:121)
at __webpack_require__ (ng2-dropdown.bundle.js:30)
at Object.<anonymous> (ng2-dropdown.bundle.js:65)
at __webpack_require__ (ng2-dropdown.bundle.js:30)
at ng2-dropdown.bundle.js:50
at ng2-dropdown.bundle.js:53
at webpackUniversalModuleDefinition (ng2-dropdown.bundle.js:3)
at Object../node_modules/ng2-tag-input/node_modules/ng2-material-dropdown/dist/ng2-dropdown.bundle.js (ng2-dropdown.bundle.js:10)
有人能指出我为什么会收到这个错误吗?我对 Angular 很陌生。先感谢您。
解决方案
看起来问题实际上出ng2-material-dropdown
在他们使用style
从@angular/core
(https://v4.angular.io/api/core/style)导入的函数的旧版本上,该函数在 Angular 4 中已弃用并移至@angular/animations
(https://v4.angular.io/api/core/style ) /angular.io/api/animations/style)
在 0.9.0 版本中,ng2-material-dropdown 库添加了对 Angular 版本 5 和 6 的支持,因此我建议您也更新该库。目前有 0.10.1 版本可用。
推荐阅读
- delphi - 从已编译的可执行文件/包中提取 ProductVersion
- sql - 错误代码:1241。尝试子查询时,操作数应包含 1 列
- javascript - 在数组中获取单个 JSON 对象
- c# - 有没有办法从 c# 将一组 SafeHandles 发送到本机函数?
- google-bigquery - 根据 id 列的条目数查询以将表中的数据聚合到另一个表中
- php - 图像和 css 未使用 PHP 在本地 wamp 服务器上加载
- reactjs - 预期 ReactBoostrap 声明或声明。TS1128
- c++ - C++ lock_guard 与 mutex.lock()
- c# - DocuSign Connect 如何配置信封以接收身份验证失败通知?
- angular - 为什么这个 ngx-leaflet 参数不能正常工作?