1

我在使用 npm start 时遇到错误。我不介意,但这会导致我无法运行服务器并查看我的本地网站。这只是因为我使用bootstrap-multiselect 插件,它没有为它创建 d.ts(打字)文件,所以在我的 ts 文件中它有一个错误,我调用 $("#category-select").multiselect({}) 说:

jquery 类型上不存在属性“多选”。

所以当我使用 npm start 时,我的终端会这样说:

Multiselect.component.ts(16,31):错误 TS2339:“JQuery”类型上不存在属性“multiselect”。

然后它不会启动本地服务器。这完全阻碍了我的工作。bootstrap-multiselect 插件非常好,我确实需要它。

我怎样才能让它忽略这个错误并继续启动本地服务器,或者阻止错误发生?

包.json:

{
  "name": "the-vegan-repository",
  "version": "1.0.0",
  "scripts": {
    "lite-server-test": "lite-server --config=liteserver-test-config.json",
    "test": "tsc && concurrently \"npm run tsc:w\" \"npm run lite-server-test\" ",
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\" \"sass --watch app\" \"sass --watch index.scss\" ",
    "lite": "lite-server",
    "postinstall": "typings install",
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "typings": "typings"
  },
  "license": "ISC",
  "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "3.0.0-beta.1",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "@angular/upgrade": "2.0.0-rc.4",
    "angular2-in-memory-web-api": "0.0.14",
    "bootstrap": "^3.3.6",
    "core-js": "^2.4.0",
    "ng2-select": "^1.0.3",
    "reflect-metadata": "^0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.27",
    "zone.js": "^0.6.12",
    "jquery": "v3.1.0"
  },
  "devDependencies": {
    "codelyzer": "0.0.26",
    "concurrently": "^2.0.0",
    "jasmine-core": "2.4.1",
    "lite-server": "^2.2.0",
    "tslint": "^3.13.0",
    "typescript": "^1.8.10",
    "typings": "^1.0.4"
  }
}
4

1 回答 1

0

我找到了这个解决方法

我只是投给任何:

(<any>$("#category-select")).multiselect();

我将暂时保留这个问题,因为可能会有更多答案。

于 2016-08-08T10:00:57.007 回答