本文整理匯總了TypeScript中tns-core-modules/http.getImage函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript getImage函數的具體用法?TypeScript getImage怎麽用?TypeScript getImage使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了getImage函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
export var test_getFile_fail = function (done) {
var result;
http.getImage({ url: "hgfttp://raw.githubusercontent.com/NativeScript/NativeScript/master/tests/app/logo.png", method: "GET", timeout: 2000 }).catch(function (e) {
result = e;
try {
TKUnit.assert(result instanceof Error, "Result from getFile().catch() should be Error! Current type is " + typeof result);
done(null);
}
catch (err) {
done(err);
}
});
};
示例2: function
export var test_getImage = function (done) {
var result;
// >> http-get-image
http.getImage("https://httpbin.org/image/png").then(function (r) {
//// Argument (r) is Image!
// >> (hide)
result = r;
try {
TKUnit.assert(result instanceof require("image-source").ImageSource, "Result from getImage() should be valid ImageSource object!");
done(null);
}
catch (err) {
done(err);
}
// << (hide)
}, function (e) {
//// Argument (e) is Error!
// >> (hide)
done(e);
// << (hide)
});
// << http-get-image
};