2012-07-16 36 views
1

我用PhoneGap NativeControls插件創建了一個ios Tabbar,當我點擊一個tabbar時,它沒有將視圖更改爲對應的html,以下是我的代碼,感謝您的任何幫助。phonegap tabbar插件無法更改頁面

這些功能是用來改變瀏覽量:

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'; 
} 

創建的TabBar:

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"); 
} 

回答

0

在我的代碼,如果在標籤欄的變化不會改變網頁通常是一個JavaScript錯誤已經停止了一切。我不明白爲什麼代碼是行不通的

也許試圖通過使用「的try-catch」 http://www.w3schools.com/js/js_try_catch.asp

+0

感謝您的回覆工作出了問題,你可以給我試玩展示瞭如何使用的TabBar PhoneGap插件?非常感謝你。 – 2012-07-26 08:05:37

+0

如果我改變這樣的功能,它可以打印出相應的信息:nativeControls.createTabBarItem( 「firstTab」, 「首頁」, 「/www/tabs/tabbar1.png」, {「onSelect」:function (){ console.log(「firstTab」); }} ); – 2012-07-26 08:11:34

相關問題