第一步 就是 单页操作完成后,通知到主框架。
这里采用的postMessage方式来实现的
window.opener.postMessage('flushDevGrid','*'); 第二步:则在主框架下监听message
//注册postMsg 用于表格刷新
$(window).bind('message', function (event) {
if(event.originalEvent&&event.originalEvent.data==='flushDevGrid'){
window.appObj.$actions.setGlobalState({flushDevGrid: window.GoingUtils.getUUid(32)});
}
});
第三步:再通过setGlobalState通知子应用
第四步:则子应用监听 $onGlobalStateChange的变化
//微前端 注册界面变化
this.$onGlobalStateChange&&this.$onGlobalStateChange((state,prev)=>{
if(state.flushDevGrid!==prev.flushDevGrid){
this.$refs.pageCard.flushCards(this.curPageId);
}
});