|
[其他]
IOS下setFrameGroupIndex不能与setFrameGroupAttr共存BUG
[复制链接]
本帖最后由 BIP322802 于 2022-1-10 22:48 编辑
情境:APP底部导航切换用了FrameGroup,点击导航菜单后调用setFrameGroupIndex切换页面,同时调用了setFrameGroupAttr设置不同页面的rect(有的页面有头部,有的没有)
BUG:安卓一切正常,当苹果loder调试时,只要页面尺寸rect变了,setFrameGroupIndex就不生效,表现为:页面实际没切换,只是头部切换了。
调试:当给setFrameGroupAttr加延时至少500时、或者去掉这个,苹果则回复正常。
代码:
- <footer class="aui-bar aui-bar-tab">
- <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item aui-active" tapmode="hover">
- <img src="./image/root/nav/11.png" alt="">
- <div class="aui-bar-tab-label">首页</div>
- </div>
- <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
- <img src="./image/root/nav/22.png" alt="">
- <div class="aui-bar-tab-label">资讯</div>
- </div>
- <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
- <img src="./image/root/nav/32.png" alt="">
- <div class="aui-bar-tab-label">商城</div>
- </div>
- <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
- <img src="./image/root/nav/42.png" alt="">
- <div class="aui-bar-tab-label">游戏</div>
- </div>
- <div onclick="randomSwitchBtn( this );" class="aui-bar-tab-item" tapmode="hover">
- <img src="./image/root/nav/52.png" alt="">
- <div class="aui-bar-tab-label">我的</div>
- </div>
- </footer>
- <script type="text/javascript">
- // 底部按钮切换
- function randomSwitchBtn(tag) {
- if (tag == $api.dom('footer .aui-bar-tab-item.aui-active')) return;
- var eFootLis = $api.domAll('footer .aui-bar-tab-item'),
- eHeaderLis = $api.domAll('header li'),
- index = 0,
- reload = false;
- //需要登录的frm
- if (tag == eFootLis[2] || tag == eFootLis[3] || tag == eFootLis[4]) {
- if (!km_islogin_app()) { //未登录
- km_open_win('public/login_win', false);
- return;
- }
- }
- //需要刷新
- if (tag == eFootLis[2] || tag == eFootLis[3]) {
- reload = true;
- }
- //底部菜单图标class切换
- for (var i = 0; i < eFootLis.length; i++) {
- if (tag == eFootLis[i]) {
- $api.addCls(eFootLis[i], 'aui-active');
- eFootLis[i].childNodes[0].src = './image/root/nav/' + (i + 1) + '1.png';
- // $api.addCls(eHeaderLis[i], 'aui-active');
- //frame判断
- index = i
- } else {
- $api.removeCls(eFootLis[i], 'aui-active');
- eFootLis[i].childNodes[0].src = './image/root/nav/' + (i + 1) + '2.png';
- // $api.removeCls(eHeaderLis[i], 'aui-active');
- }
- }
- // 切换frm内容
- api.setFrameGroupIndex({
- name: 'group_root',
- index: index,
- scroll: true, //是否平滑滚动至目标窗口,即是否带有动画
- reload: reload, //是否刷新 frame
- });
- // 通过改变rect实现显示隐藏win的标题栏
- if (tag == eFootLis[0]) {
- rect = {
- x: 0,
- y: $api.offset($api.dom('header')).h - 2,
- w: 'auto',
- h: $api.offset($api.dom('footer')).t - $api.offset($api.dom('header')).h + 2
- };
- } else {
- rect = {
- x: 0,
- y: 0,
- w: 'auto',
- h: $api.offset($api.dom('footer')).t + 1
- };
- }
- // setTimeout(function() {
- api.setFrameGroupAttr({
- name: 'group_root',
- rect: rect,
- });
- // }, 500);
- }
- </script>
复制代码
|
|