子域监听不到主域发的消息,并报错
发布于 6 年前 作者 baimin 2212 次浏览 来自 问答
  • 当前 Bug 的表现(可附上截图)
  • 预期表现
  • 复现路径
  • 提供一个最简复现 Demo

主域发消息

let openDataContext = wx.getOpenDataContext()

openDataContext.postMessage({

type: ‘freinds’,

width: screenWidth,

height: windowHeight,

})

开放域接收消息

wx.onMessage(data => {

console.log(‘start2’)

})

报错:

gameThirdScriptError https://lib/WAGameSubContext.js:1: fromIndex(2) > toIndex(1) 

https://lib/WAGameSubContext.js:1: fromIndex(2) > toIndex(1)

<div class=“eruda-json eruda-hidden”></div>

at e.value (wagame://WAGameVConsole.html:27576:37881)

at new e (wagame://WAGameVConsole.html:27576:36645)

at t.value (wagame://WAGameVConsole.html:27576:32217)

at t.value (wagame://WAGameVConsole.html:27576:31461)

at f.e.(anonymous function) [as error] (wagame://WAGameVConsole.html:27576:16382)

at wagame://WAGameVConsole.html:27576:19192

at Array.forEach (<anonymous>)

at console._log (wagame://WAGameVConsole.html:27576:19080)

at <anonymous>:1:9

模拟器上主域子域可以正常通信,但是真机上无法通信

回到顶部