与openfin一样,我们可以单独打开单独的小部件/窗口,它们如何相互通信,搜索了很多次也找不到任何相关信息,请帮助。
发布于 2020-04-19 18:08:46
您可以使用customContext将上下文从主窗口共享到其所有父视图
窗口(框架)中的
const me = fin.Window.getCurrentSync();
me.on('options-changed', async (event) => {
if (event.diff.customContext) {
const myViews = await me.getCurrentViews();
const customContext = event.diff.customContext.newVal;
myViews.forEach(v => {
v.updateOptions({ customContext });
});
}
})视图中的(内容)
const me = fin.View.getCurrentSync();
const broadcastContext = async (customContext) => {
const myWindow = await me.getCurrentWindow()
await myWindow.updateOptions({ customContext })
};
const addContextListener = async (listener) => {
await me.on('options-changed', (event) => {
if (event.diff.customContext) {
listener(event.diff.customContext.newVal);
}
});
}参考资料- https://cdn.openfin.co/docs/javascript/stable/tutorial-customContext.html
https://stackoverflow.com/questions/59776654
复制相似问题