我使用PhoneGap NativeControls Plugins创建了一个ios Tabbar,当我点击一个tabbar时,它并没有将视图更改为相应的html,以下是我的代码,感谢您的帮助。
这些函数用于改变浏览量:
function showFirstPage()
{
window.location.href = 'firstTab.html';
}
function showSecondPage()
{
window.location.href = 'secondTab.html';
}
function showThirdPage()
{
window.location.href = 'thirdTab.html';
}
function showFourthPage()
{
window.location.href = 'fourthTab.html';
}
function showFifthPage()
{
window.location.href = 'fifthTab.html';
}
创建一个标签栏:
function onBodyLoad()
{
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
// Initializating TabBar
nativeControls = window.plugins.nativeControls;
nativeControls.createTabBar();
// 首页
nativeControls.createTabBarItem(
"firstTab",
"首页",
"/www/tabs/tabbar1.png",
{"onSelect": function() {
//console.log("firstTab");
showFirstPage();
}}
);
// 版块
nativeControls.createTabBarItem(
"secondTab",
"版块",
"/www/tabs/tabbar2.png",
{"onSelect": function() {
//console.log("secondTab");
showSecondPage();
}}
);
// 贴图
nativeControls.createTabBarItem(
"thirdTab",
"贴图",
"/www/tabs/tabbar3.png",
{"onSelect": function() {
//console.log("thirdTab");
showThirdPage();
}}
);
// 个人中心
nativeControls.createTabBarItem(
"fourthTab",
"个人中心",
"/www/tabs/tabbar4.png",
{"onSelect": function() {
//console.log("fourthTab");
showFourthPage();
}}
);
// 更多
nativeControls.createTabBarItem(
"fifthTab",
"更多",
"/www/tabs/tabbar5.png",
{"onSelect": function() {
//console.log("fifthTab");
showFifthPage();
}}
);
// Compile the TabBar
nativeControls.showTabBar();
nativeControls.showTabBarItems("firstTab", "secondTab", "thirdTab", "fourthTab", "fifthTab");
nativeControls.selectTabBarItem("firstTab");
}