【发布时间】:2016-08-04 16:30:50
【问题描述】:
我想在已经可用的 Ti.Network.HTTPClient 上编写我的自定义 OauthClient。
我尝试使用以下代码继承它:
function OAuthClient (params) {
Ti.Network.HTTPClient.call(this, params);
}
OAuthClient.prototype = Object.create(Ti.Network.HTTPClient.prototype);
OAuthClient.prototype.constructor = Ti.Network.HTTPClient;
但是当我尝试如下创建一个新的 OAuthClient 时
var client = new OAuthClient({
onload: function() {},
onerror: function() {}
});
我收到以下错误:
[ERROR] : TypeError: Illegal invocation
[ERROR] : File: app.js
[ERROR] : Line: undefined
[ERROR] : SourceId: undefined
[ERROR] : Backtrace:
[ERROR] : undefined
在 Titanium 中编写自定义 HttpClient 的正确方法是什么?
谢谢!
【问题讨论】:
-
你有没有试过调查这个项目:github.com/viezel/napp.alloy.adapter.restapi
标签: inheritance titanium httpclient appcelerator