Blend UI 页面控制 API

2018-10-17 11:34 更新

Control

removeSplashScreen ( )

去除启动屏幕(仅Native App可用)
Blend.ui.removeSplashScreen();


实例

document.addEventListener("blendready",function(){
    Blend.ui.removeSplashScreen();
});


exitApp ( )

退出应用(仅Native App可用)
Blend.ui.exitApp();


实例

document.addEventListener("blendready",function(){
    //监听系统消息,弹出退出确认框
    Blend.ui.on("backPressedBeforeExit",function(e){
    //Android系统按下返回键的消息为backPressedBeforeExit
        if(window.confirm("确定要退出吗?")){
             Blend.ui.exitApp();
        }
    });
});


layerStopRefresh ( [layerId] ) : String

停止下拉刷新,需要配置页面刷新相关参数并注册"layerPullDown"下拉事件响应。
Blend.ui.layerStopRefresh([layerId]);
参数类型说明是否必须
layerIdString停止对应id的layer下拉刷新功能,默认停止当前页面下拉刷新功能。

返回 * layerId : String 停止刷新操作的id 实例

document.addEventListener("blendready", function() {
    Blend.ui.layerInit("0", function(dom) {
        var contentLayer = new Blend.ui.Layer({
            "id": "contentLayerId",
            "url": "content.html",
            "active": true,
            "pullToRefresh":true,
            "pullText":"下拉可以刷新⊙0⊙",
            "loadingText":"更新中,请等待...",
            "releaseText":"释放更新⊙0⊙"
        });

        Blend.ui.on("layerPullDown",function(event){
            //模拟一次http请求操作
            setTimeout(function(){
                $("#content", dom).prepend("刷新操作");
                //到了5秒后将会停止页面下拉刷新状态
                Blend.ui.layerStopRefresh("contentLayerId");
            },5000);
        });
    });
});


layerBack ( [layerId] )

退出当前layer,显示layerId对应的页面
Blend.ui.layerBack([layerId])
参数类型说明是否必须
layerIdString退出当前页面后要显示的页面id

实例

//script脚本部分代码
     var layer = new Blend.ui.Layer({
        "url":"content.html",
        "id":"contentLayer",
        "active":true
     });
     Blend.ui.layerBack();


layerStopLoading ([layerId])

消除页面的loading样式

Blend.ui.layerStopLoading([layerId])
参数类型说明是否必须
layerIdString消除id为layerId的页面loading样式,默认消除当前页面loading样式。


返回

  • layerId : String 消除页面的loading样式的id


实例

document.addEventListener("blendready", function() {
    Blend.ui.layerInit("0", function(dom) {
        //点击按钮切换页面
        $('#button', dom).click(function(e) {
            Blend.ui.fire("createContentLayer", "0");
        });

        var contentLayer;
        Blend.ui.on("createContentLayer", function(event) {
            if (contentLayer) {
                contentLayer.in();
            } else {
                contentLayer = new Blend.ui.Layer({
                    "id": "contentLayerId",
                    "url": "content.html",
                    "active": true,
                    "autoStopLoading":false,
                    "maxLoadingTime":1000,
                    "loadingIcon":"base64图片字符串,不包含头"
                });
            }
        });
    });
});
以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号