1

在更新到 tns 核心模块 2.2.0 和 angular rc4(telerik 正式发布的版本)时,我的应用程序无法再对服务器进行 http 调用,我不断收到此错误

com.tns.NativeScriptException: 
Calling js method onClick failed

EXCEPTION: Error in /data/data/org.nativescript.EatSafe/files/app/pages/login/login.html:5:75
ORIGINAL EXCEPTION: Error: not implemented
ORIGINAL STACKTRACE:
Error: not implemented
    at NativeScriptDomAdapter.Parse5DomAdapter.getCookie (/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/platform-server/src/parse5_adapter.js:619:68)
    at CookieXSRFStrategy.configureRequest (/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/http/src/backends/xhr_backend.js:150:82)
    at XHRBackend.createConnection (/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/http/src/backends/xhr_backend.js:165:28)
    at httpRequest (/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/http/src/http.js:22:20)
    at Http.post (/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/http/src/http.js:78:16)
    at UserService.signin (/data/data/org.nativescript.EatSafe/files/app/shared/services/user.service.js:13:27)
    at LoginComponent.login (/data/data/org.nativescript.EatSafe/files/app/pages/login/login.component.js:31:27)
    at DebugAppView._View_LoginComponent0._handle_tap_8_0 (LoginComponent.template.js:355:28)
    at /data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/core/src/linker/view.js:375:24
    at /data/data/org.nativescript.EatSafe/files/app/tns_modules/nativescript-angular/renderer.js:204:26
ERROR CONTEXT:
[object Object]
File: "/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/core/src/linker/view.js, line: 365, column: 16

StackTrace: 
    Frame: function:'DebugAppView._rethrowWithContext', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/core/src/linker/view.js', line: 365, column: 17
    Frame: function:'', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/core/src/linker/view.js', line: 378, column: 23
    Frame: function:'', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/nativescript-angular/renderer.js', line: 204, column: 26
    Frame: function:'ZoneDelegate.invoke', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/zone.js/dist/zone-node.js', line: 290, column: 29
    Frame: function:'NgZoneImpl.inner.inner.fork.onInvoke', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/core/src/zone/ng_zone_impl.js', line: 53, column: 41
    Frame: function:'ZoneDelegate.invoke', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/zone.js/dist/zone-node.js', line: 289, column: 35
    Frame: function:'Zone.run', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/zone.js/dist/zone-node.js', line: 183, column: 44
    Frame: function:'NgZoneImpl.runInner', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/core/src/zone/ng_zone_impl.js', line: 84, column: 71
    Frame: function:'NgZone.run', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/@angular/core/src/zone/ng_zone.js', line: 235, column: 66
    Frame: function:'zonedCallback', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/nativescript-angular/renderer.js', line: 203, column: 24
    Frame: function:'Observable.notify', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/data/observable/observable.js', line: 174, column: 23
    Frame: function:'Observable._emit', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/data/observable/observable.js', line: 193, column: 18
    Frame: function:'_android.setOnClickListener.android.view.View.OnClickListener.onClick', file:'/data/data/org.nativescript.EatSafe/files/app/tns_modules/ui/button/button.js', line: 33, column: 32


    at com.tns.Runtime.callJSMethodNative(Native Method)
    at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:862)
    at com.tns.Runtime.callJSMethodImpl(Runtime.java:727)
    at com.tns.Runtime.callJSMethod(Runtime.java:713)
    at com.tns.Runtime.callJSMethod(Runtime.java:694)
    at com.tns.Runtime.callJSMethod(Runtime.java:684)
    at com.tns.gen.android.view.View_OnClickListener.onClick(View_OnClickListener.java:11)
    at android.view.View.performClick(View.java:5233)
    at android.view.View$PerformClick.run(View.java:21209)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:152)
    at android.app.ActivityThread.main(ActivityThread.java:5507)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

我一直在尝试在线查找更新的发布日志,以查看是否有任何重大更改,但无济于事。有人对如何使用新的 nativescript 角度更新进行 http 调用有任何指示吗?

谢谢

4

2 回答 2

2

我通过导入app.moudle.ts以下内容解决了这个问题

import {NativeScriptHttpModule} from 'nativescript-angular/http';

接着

 imports: [NativeScriptHttpModule]
于 2017-06-07T03:46:30.310 回答
1

您需要在 main.ts 文件中使用此代码

import {Parse5DomAdapter} from '@angular/platform-server/src/parse5_adapter';

(<any>Parse5DomAdapter).prototype.getCookie = function (name) { return null; };
于 2016-08-20T19:54:46.007 回答