postMessage总是returns错误数据?

postMessage always returns wrong data?

我的目标是单击当前选项卡中的一个按钮,它将打开一个新选项卡,并在新选项卡的 Chrome 开发工具中使用 post消息 API:

window.opener.postMessage({deliveryId: 18042548, materialId: 1051041576634029702},'*')

当前标签已经添加了onmessage事件,会检查来源,console.log数据:

window.addEventListener("message", this.syncDirectMaterialTag)
syncDirectMaterialTag = async e => {
    if ('http://beta-ace.jd.com' === e.origin) {
      console.log(e.data)
      //const res = await queryDirMaterialTag(mapper)
    }
  }

但它总是 returns 我收到同样的错误信息 post:

deliveryId: 18042548
materialId: 1051041576634029700

怎么可能???

我已经修复了。

原因是JavaScript失去了准确性。

所以materialId的类型应该是String:

window.opener.postMessage({deliveryId: 18042548, materialId: '1051041576634029702'},'*')