Blend UI 頁面控制 API

2018-10-17 11:34 更新

Control

removeSplashScreen ( )

去除啟動屏幕(僅Native App可用)
Blend.ui.removeSplashScreen();


實例

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


exitApp ( )

退出應(yīng)用(僅Native App可用)
Blend.ui.exitApp();


實例

document.addEventListener("blendready",function(){
    //監(jiān)聽系統(tǒng)消息,彈出退出確認框
    Blend.ui.on("backPressedBeforeExit",function(e){
    //Android系統(tǒng)按下返回鍵的消息為backPressedBeforeExit
        if(window.confirm("確定要退出嗎?")){
             Blend.ui.exitApp();
        }
    });
});


layerStopRefresh ( [layerId] ) : String

停止下拉刷新,需要配置頁面刷新相關(guān)參數(shù)并注冊"layerPullDown"下拉事件響應(yīng)。
Blend.ui.layerStopRefresh([layerId]);
參數(shù)類型說明是否必須
layerIdString停止對應(yīng)id的layer下拉刷新功能,默認停止當(dāng)前頁面下拉刷新功能。

返回 * 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秒后將會停止頁面下拉刷新狀態(tài)
                Blend.ui.layerStopRefresh("contentLayerId");
            },5000);
        });
    });
});


layerBack ( [layerId] )

退出當(dāng)前l(fā)ayer,顯示layerId對應(yīng)的頁面
Blend.ui.layerBack([layerId])
參數(shù)類型說明是否必須
layerIdString退出當(dāng)前頁面后要顯示的頁面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])
參數(shù)類型說明是否必須
layerIdString消除id為layerId的頁面loading樣式,默認消除當(dāng)前頁面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圖片字符串,不包含頭"
                });
            }
        });
    });
});
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號