WeexViewController
WeexViewController 是weex的容器,负责渲染weex页面。
Component
WXSelectComponent
选择器组件
Handle
WXImgLoaderDefaultImpl
图片下载
Module
WXNetworkModule
网络请求模块
发起网络请求 API
request(options, callback)
options {Object}
:请求的一些选项
url {string}
:请求的 URLmethod {string}
:HTTP 方法GET
或是POST
headers {Object}
:HTTP 请求头type {string}
:响应类型,json
或者text
body {string}
:HTTP 请求体。注意:
body
参数仅支持string
类型的参数,请勿直接传递JSON
,必须先将其转为字符串。GET
请求不支持body
方式传递参数,请使用 url 传参。callback {Function}
:响应结果回调,回调函数将收到如下的response
对象:status {number}
:返回的状态码ok {boolean}
:如果状态码在 200~299 之间就为真。statusText {string}
:状态描述文本data {Object | string}
: 返回的数据,如果请求类型是json
,则它就是一个 object ,如果不是,则它就是一个 string。headers {Object}
:响应头
例子:
const network = weex.requireModule('network');
network.request({
url: 'https://abc.com',
method: 'POST',
body: JSON.stringify({ key: 'value' }),
type: 'json',
headers: { 'X-Requested-With': 'OpenAPIRequest', 'Content-Type': 'application/json' },
}, (response) => {
});
WXRouteModule
路由跳转模块
const route = weex.requireModule('route');
const params = encodeURIComponent(JSON.stringify({ code: '1' }));
const url = `cenarius://route/product?params=${params}`;
route.open(url);
WXProgressHUDModule
菊花模块
const progressHUD = weex.requireModule('progressHUD');
progressHUD.show();
progressHUD.dismiss();
WXToastModule
吐司模块
const toast = weex.requireModule('toast');
toast.show(options);
options {Object}
:请求的一些选项
message {string}
:展示的内容duration {number}
:展示的持续时间(以秒为单位)