Back

javascript - electron 中的 奇怪报错:Failed to execute 'postMessage' on 'Window': 2 arguments required, but only 1 present.

发布时间: 2021-06-12 10:12:00

2021-12-18  知道了:是setTimeout 中有错误造成的。

解决办法: 把timeout中的函数拿出来单独运行,就可以看到报错具体的文字了

两个都是一个原因:没有找到对应的方法

情况1

使用 

setTimeout( function (){  not_exist_function() } ,  100 ) 之后

会报错 

Failed to execute 'postMessage' on 'Window': 2 arguments required, but only 1 present.

需要把上面的不存在的方法,改成存在的方法就可以了。 例如

setTimeout( function (){  correct_function() } , 100 ) 之后

情况2

对应的package 没有安装。(检查package.json ,是放在了devDependency中,应该放在 dependency中)

所以,

Back