我正在尝试使用 physi.js 库 ()。我遵循了所有给出的步骤:
https://github.com/chandlerprall/Physijs/wiki/Basic-Setup
但是,我得到了错误:
Uncaught SecurityError: Failed to construct 'Worker': Script at 'file://172.16.159.200/js/physijs_worker.js' cannot be accessed from origin 'null'.
我试着更深入一些,发现问题出在这条线上:
this._worker = new Worker( Physijs.scripts.worker || 'physijs_worker.js' );
是什么导致了这个问题?浏览器是谷歌浏览器。我检查过,文件“physijs_worker.js”出现在正确的位置。
最佳答案
浏览器不允许从本地文件创建 worker,因为那会是一个安全问题。
另见这个问题:
Why does not Chrome allow Web Workers to be run in JavaScript?
关于javascript - "physi.js"导致错误 : "Script cannot be accessed from origin ' null '",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30202529/