窗口之间的传值

2021-06-23  本文已影响0人  废弃的种子
/**
 * @desc   打开一个新窗口
 * @param {(Object vue实例this)} vue
 * @param {Object} params
 * @returns {string}
 */
Common.windowOpen = function(vue, params, name = "_blank") {
  const routeData = vue.$router.resolve(params);
  const opener = window.open(routeData.href, name);
  return opener;
};
//父
 addHouseholdsTable() {
      this.Common.windowOpen(this, { path: '/printChangeOfPovertyAlleviation/ChangeOfPovertyAlleviation', query: {
        type: 3
      }});
      const self = this;
      window.addEventListener('message', function(e) {
        const data = e.data;
        if (data === 'successSaveCheckForm') {
          self.getList(); ;
        }
      });
    },
      
 //子
window.opener.postMessage('successSaveCheckForm', '*');
上一篇下一篇

猜你喜欢

热点阅读