Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我知道web workers工作作为一个单独的线程而不是,UI thread但我不明白为什么不允许他们修改DOM. 我的意思是您可以允许线程间通信并将DOM数据保存在共享空间中并让web workers线程修改DOM. 为什么浏览器不允许这样做?
web workers
UI thread
DOM
因为 DOM 不是线程安全的,并且 JavaScript 没有公开线程 API。
也可以看看: