小程序動態設置 tabBar 某一項的內容wx.setTabBarItem
wx.setTabBarItem(Object object)
動態設置 tabBar 某一項的內容,2.7.0 起圖片支持臨時文件和網絡文件。
參數
Object object
屬性 類型 默認值 必填 說明
index number 是 tabBar 的哪一項,從左邊算起
text string 否 tab 上的按鈕文字
iconPath string 否 圖片路徑,icon 大小限制為 40kb,建議尺寸為 81px * 81px,當 postion 為 top 時,此參數無效
selectedIconPath string 否 選中時的圖片路徑,icon 大小限制為 40kb,建議尺寸為 81px * 81px ,當 postion 為 top 時,此參數無效
success function 否 接口調用成功的回調函數
fail function 否 接口調用失敗的回調函數
complete function 否 接口調用結束的回調函數(調用成功、失敗都會執行)
示例代碼
wx.setTabBarItem({
index: 0,
text: 'text',
iconPath: '/path/to/iconPath',
selectedIconPath: '/path/to/selectedIconPath'
})