swan.setTabBarItem

    Object object

    扫码体验

    代码示例

    请使用百度APP扫码

    图片示例

    在开发者工具中打开

    在 WEB IDE 中打开

    • SWAN
    • JS

    代码示例 2:切换 tab 时变化文案

    在开发者工具中打开

    在 WEB IDE 中打开

    1. Page({
    2. onTabItemTap(item) {
    3. console.log('点击第几项', item.index);
    4. if (item.index == 1) {
    5. this.setTabBarItem(item.index)
    6. }
    7. console.log('点击tab对应的路径', item.pagePath);
    8. },
    9. setTabBarItem(index) {
    10. swan.setTabBarItem({
    11. text: '替换文本',
    12. iconPath: '/images/component_normal.png',
    13. selectedIconPath: '/images/component_selected.png',
    14. console.log('setTabBarItem success');
    15. },
    16. fail: err => {
    17. console.log('setTabBarItem fail', err);
    18. }
    19. });
    20. }
    21. });

    iOS