帖子
帖子
用户
博客
课程
显示全部楼层
7
帖子
0
勋章
75
Y币

[多端开发] tabbar跳转问题

[复制链接]
发表于 2024-4-2 16:45:40
求助
我是这样打开了个有着tabbar的页面,然后现在需求是,点击第二个tabbar页面内容时候,会显示一个全屏的内容,点击这个全屏的内容的关闭按钮希望跳转到第一个tabbar上,不知道该怎么处理
尝试过api.openTabLayout但是打开的是一个没有tabbar的页面

也尝试过把下面那个重新调用一次,但是发现相当于是打开了两个然后页面就很卡


api.openTabLayout({
    name: 'main_xinghuo',
    url: 'widget://html/main/main_xinghuo.html',
    hideTabBar: false,
    slidBackEnabled: false,
    bgColor: "#fff",
    tabBar: {
       height: TabBarHeight,
       background: '#fff',
       shadow: '#EBEEF4',
       color: '#999999',
       selectedColor: '#1669FF',
       textOffset: 4,
       fontSize: 11,
       scrollEnabled: false,
       preload: 0,
       list: [{
          text: '资讯',
          iconPath: 'widget://icon/xinghuo0.png',
          selectedIconPath: 'widget://icon/xinghuo1.png'
       },
          {
             text: '生态',
             iconPath: 'widget://icon/icon_xinghuoshijie_normal.png',
             selectedIconPath: 'widget://icon/icon_xinghuoshijie_selected.png'
          },
          {
             text: '智库',
             iconPath: 'widget://icon/icon_zhuanshuzhiku_normal.png',
             selectedIconPath: 'widget://icon/icon_zhuanshuzhiku_selected.png'
          },
          {
             text: '活动',
             iconPath: 'widget://icon/icon_huiyihuodong_normal.png',
             selectedIconPath: 'widget://icon/icon_huiyihuodong_selected.png'
          },
          {
             text: '我的',
             iconPath: 'widget://icon/mime0.png',
             selectedIconPath: 'widget://icon/mime1.png'
          }
       ],
       frames: [
          {
             name: 'main_xinghuo',
             url: 'widget://html/main/main_xinghuo.html',
             bounces: false
          },
          {
             name: 'main_xinghuo_home',
             url: 'widget://html/main/main_xinghuo_home.html',
             bounces: false
          },
          {
             name: 'main_storehouse',
             url: 'widget://html/main/main_storehouse.html',
             bounces: false
          },
          {
             name: 'main_xinghuo_activity',
             url: 'widget://html/main/main_xinghuo_activity.html',
             bounces: false
          },
          {
             name: 'main_mime',
             url: 'widget://html/main/main_mime.html',
             bounces: true
          }
       ]
    }
});
0
帖子
2
勋章
1079
Y币
使用setTabBarAttr,设置index,即可实现tab页面的切换 https://developer.yonyou.com/docs/Client-API/API#setTabBarAttr

使用api.addEventListener监听'tabframe'事件,可以监听tab页面切换事件https://developer.yonyou.com/docs/Client-API/API#tabframe
7
帖子
0
勋章
75
Y币
至高吾·尚 · 2024-4-2 16:54使用setTabBarAttr,设置index,即可实现tab页面的切换 https://developer.yonyou.com/docs/Client-API/API#setTabBarAttr

使用api.addEventListener监听'tabframe'事件,可以监听tab页面切换事件https://developer ...

尝试过, setTabBarAttr是更改属性 更改了index之后并不能切换过去,
下面那个监听确实可以监听到

api.setTabBarAttr({
                                        index: 0
                                });
0
帖子
2
勋章
1079
Y币
本帖最后由 vaptu 于 2024-4-2 17:31 编辑

那就是你的代码有问题,这个API主要就是做这个用的

你可以新建一个测试项目,写4个简单页面自己测试下

  1. // 切换tabBar
  2. api.setTabBarAttr({
  3.         index: pIndex
  4. });
复制代码

7
帖子
0
勋章
75
Y币
至高吾·尚 · 2024-4-2 17:30那就是你的代码有问题,这个API主要就是做这个用的

你可以新建一个测试项目,写4个简单页面自己测试下

我再尝试一下看看 谢谢
7
帖子
0
勋章
75
Y币
至高吾·尚 · 2024-4-2 17:30那就是你的代码有问题,这个API主要就是做这个用的

你可以新建一个测试项目,写4个简单页面自己测试下

发现他之前写的是在第二个tabbar里面内容是openwin了个新页面,所以在新页面里面设置index是不生效的。如果不用setTabBarAttr有其他跳转过去吗,类似底部菜单栏的效果
0
帖子
2
勋章
1079
Y币
现切换index,让tab在底层跳转到首页,然后再执行api.closeWin关闭open的那个Win
您需要登录后才可以回帖 登录

本版积分规则