使用angular2和angular-cli构建应用程序时出现奇怪的错误。 错误消息是:
themes.js:236 Uncaught TypeError: $.holdReady is not a function
我的Package.json
{
"name": "app2.0",
"version": "0.0.0",
"license": "MIT",
"scripts": {
// scripts here
},
"private": true,
"dependencies": {
// angular2 packages here
"core-js": "^2.4.1",
"devextreme": "^16.2.5",
"devextreme-angular": "^16.2.5",
"ng2-dropdown-multiselect": "^1.1.1",
"rxjs": "^5.1.0",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/cli": "1.0.0-rc.1",
"@angular/compiler-cli": "^2.4.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.4.2",
"typescript": "~2.0.0"
}
}
答案 0 :(得分:3)
devextreme-angular
依赖于jquery ^3.0.0
根据jquery changelog https://blog.jquery.com/ 从3.2.0开始,jQuery.holdReady已被弃用。
所以你的解决方案可能是降级jquery至少3.1.1,例如你可以使用npm-shrinkwrap.json
来冻结jquery版本
答案 1 :(得分:0)
问题是由项目中使用的jQuery版本引起的。我认为这是3.2.0。 jQuery在此版本中有以下错误:$.holdReady is broken in 3.2.0。尽管事件$.holdReady
is deprecated in jQuery 3.2.0,但它不应该从$
变量中删除。我相信jQuery团队将在他们的下一个版本中解决这个问题。与此同时,DevExpress也将解决这个问题。请参阅DevExtreme fails with the "$.holdReady is not a function" error when jQuery 3.2.0 is used错误报告。
目前,我建议您在项目中使用jQuery 3.1.1:
npm i --save jquery@3.1.1