window.postMessage(JSON.stringify({
type: 'loggedIn',
userToken: token,
}));
我的问题来自上面的代码。
它在 ios 设备上给了我 TypeError: Not enough argument
。
如果您遇到此问题,请帮助我。
谢谢
最佳答案
您没有提供两个必需的参数。来自 MDN documentation :
targetWindow.postMessage(message, targetOrigin, [transfer]);
请注意,targetOrigin
不是可选的。指定消息的目标来源,例如:
window.postMessage(JSON.stringify({
type: 'loggedIn',
userToken: token,
}), window.origin);
关于javascript - IOS 上的类型错误 : Not enough arguments with window. postMessage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60737331/