Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
358 views
in Technique[技术] by (71.8m points)

Weex 导航到选中 tabbar item 扩展方法

android平台 weex sdk 0.10.0

tabbar是在 instanceId =1
在当前实例很简单,在其他 instance时候,如何切回 tabbar的某一项,没有对应方法。

看文档,我的思路是 BroadcastChannel在不同实例通讯完成

const broadCastChannel = new BroadcastChannel('tab');
    //bind message handler
    broadCastChannel.onmessage = function (event) {
      console.log(event.data);
    }

其他实例 调用下面方法 postMessage

var tabChannel;
function tab(url){
    tabChannel = new BroadcastChannel('tab');
    tabChannel.postMessage(url);
    tabChannel.close();
    tabChannel = null;
}

真机运行,以为可以解决了,实际运行 BroadcastChannel is not defined,那就是 js框架不支持
BroadcastChannel ,不知道怎么弄了,有朋友有解决方法吗?在其他实例,切回 tabbar的某一项,

思路2:
js getInstance 获取到 instanceId=1 这个实例,不知道这个思路是否可行,js 有无 getInstace 方法


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

看了下 BroadcastChannel 原来 vue的没有注入 service,注入就可以用了....


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...