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