Nativescript 2.2 exception

≡放荡痞女 提交于 2020-01-02 14:38:26

问题


Getting the following exception with 2.2.

Was working with previous version.

Did "tns info" and all is updated to 2.2

JS: Error: Uncaught (in promise): EXCEPTION: Error in pages/listview/listview.html:12:2
JS: ORIGINAL EXCEPTION: TypeError: _this.cssClasses(...).set is not a function
JS: ORIGINAL STACKTRACE:
JS: TypeError: _this.cssClasses(...).set is not a function
JS:     at /data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:254:78
JS:     at Array.forEach (native)
JS:     at ViewUtil.setClasses (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:254:17)
JS:     at ViewUtil.setPropertyInternal (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:189:18)
JS:     at ViewUtil.setProperty (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/view-util.js:181:18)
JS:     at NativeScriptRenderer.setElementProperty (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/renderer.js:141:23)
JS:     at NativeScriptRenderer.setElementAttribute (/data/data/org.nativescript.test1/files/app/tns_modules/nativescript-angular/renderer.js:145:21)
JS:     at DebugAppView._View_ListviewPage0.createInternal (ListviewPage.template.js:58:17)
JS:     at DebugAppView.AppView.create (/data/data/org.nativescript.test1/files/app/tns_modules/@angular/core/src/linker/view.js:87:21)
JS:     at DebugAppView.create (/data/data/org.nativescript.test1/files/app/tns_modules/@angular/core/src/linker/view.js:299:44)
JS: ERROR CONTEXT:
JS: [object Object]

回答1:


I tested this scenario with latest tns-core-modules and nativescript-angular and everything works as expected. As @Panayot.Cankov suggested you should upgrade to tns-core-modules@2.2.0 and nativescript-angular@0.3.0. You could do that using following commands:

  1. tns plugin remove tns-core-modules
  2. tns plugin add tns-core-modules@2.2.0
  3. tns plugin remove nativescript-angular
  4. tns plugin add nativescript-angular@0.3.0



回答2:


Upgrade both the tns-core-modules@2.2.0 and nativescript-angular@0.3.0. After some refactoring we introduced the cssClasses Set on the View classes in the tns-core-modules but by unhappy coincidence the nativescript-angular was extending by monkey-patching its own cssClasses Array property on the View class. It has been resolved, but new versions of the tns-core-modules will not be compatible with old versions of the nativescript-angular.




回答3:


Make sure you upgrade your angular dependencies too, i was receiving the same error until i bumped to rc4. the below dependencies work for me now.

"@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@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/platform-server": "2.0.0-rc.4",
    "@angular/router-deprecated": "2.0.0-rc.2",
    "nativescript-angular": "^0.3.0",
    "nativescript-drop-down": "^1.3.2",
    "rxjs": "5.0.0-beta.6",
    "tns-core-modules": "^2.2.1",
    "zone.js": "^0.6.12"


来源:https://stackoverflow.com/questions/38906245/nativescript-2-2-exception

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!