利用appframework自带的一些方法可以设置页面的内容,比如设置返回的内容,默认是”
$.afui.setBackButtonText("返回");//设置back为返回
$.afui.setBackButtonVisibility(false);//隐藏返回键
但是我不建议这么做,因为你这样子改,默认加载的时候还是会出现”
//appframework.ui.js
showBackButton:function(view,isNewView) {
var items=(this.views[view.prop("id")].length);
var hdr=view.children("header");
if(hdr.length===0) return;
if(items>=2&&isNewView!==true){
//Add the back button if it's not there
if(hdr.find(".backButton").length===1) return;
//默认隐藏
hdr.prepend("<a class='backButton back' style='visibility: hidden'>" + this.backButtonText + "</a>");
}
else {
hdr.find(".backButton").remove();
}
}
这里就是返回按钮的修改地方
PS,在appframework3.0之前会使用data-load,data-unload,这两种方法也挺好用的,现在3.0已经去掉了这个方法,我在这里把代码贴出来,需要的可以用
//js文件添加这个代码
function dispatchPanelEvent(fnc,myPanel){
if (typeof fnc === "string" && window[fnc]) {
return window[fnc](myPanel);
}
else if(fnc.indexOf(".")!==-1){
var scope=window,items=fnc.split("."),len=items.length,i=0;
for(i;i<len-1;i++){
scope=scope[items[i]];
if(scope===undefined) return;
}
return scope[items[i]](myPanel);
}
}
$(document).on("panelload",function(e){
var hasLoad=$(e.target).attr("data-load");
return dispatchPanelEvent(hasLoad,e.target);
})
$(document).on("panelunload",function(e){
var hasLoad=$(e.target).attr("data-unload");
return dispatchPanelEvent(hasLoad,e.target);
})
页面设置
<div class="panel" data-title="Favorites" id="foobar" data-load="setHideBackButton">
</div>
//js代码 这里不能传参数
function setHideBackButton() {
$.afui.setBackButtonVisibility(false);
}
关于学习appframework,这里只是我一家之言,可能很多地方有不完善或者不对的地方,欢迎大家批评指正。