【问题标题】:Angular (4.1.3) ng-select2 Error角(4.1.3)ng-select2错误
【发布时间】:2018-10-18 02:33:18
【问题描述】:

我安装了ng-select2 package。而且我收到此错误,并且在“ng serve”之后代码无法编译。

  • 节点版本为8.10.0
  • npm 版本 6.0.0
  • 列表项

操作系统 Windows 7

ERROR in d:/PATH-TO-PROJECT-FOLDER/node_modules/@types/select2/index.d.ts (233,49): 'JQuery' only refers to a type, but is being used as a namespace here.

ERROR in D:/PATH-TO-PROJECT-FOLDER/node_modules/ng-select2/ng-select2/ng-select2.component.ts (188,18): Cannot find name 'Select2Options'.

ERROR in /src/app/pages/dashboard/dashboard.component.ts (91,19): Cannot find name 'Select2Options'.

// Dashboard component ts(91, 19) error + I've also added import to it:
public options: Select2Options;

我尝试过的解决方案是:

  • 根据文档,添加 import 并在 @NgModule 中导入 app.module.ts
  • 我也安装了 jquery@3.2.1 和 @types/jquery@2.0.41。
  • npm cache verify,然后 npm cache clean --force 并更新 npm
  • 删除 package-lock.json 然后运行 ​​npm install 但这似乎不起作用。

【问题讨论】:

    标签: javascript node.js angular npm


    【解决方案1】:

    如 github 问题所述: 在最新版本 4.0.45 中,接口 Select2Options 被移除/重命名为 Options

    要解决这个问题,我只需通过运行将包降级到 4.0.44 npm install @ types/select2@4.0.44 --save 这对我有用。

    https://github.com/NejcZdovc/ng2-select2/issues/124

    【讨论】:

    • 我没有那个名声。我认为它必须在 15 岁以上!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-07
    • 1970-01-01
    • 2017-07-14
    • 2014-01-17
    • 2016-01-21
    • 2017-07-15
    相关资源
    最近更新 更多