简体   繁体   English

服务人员获取数据/使用dom

[英]Service worker fetching data / working with dom

How can I fetch and manipulate some data from server (firebase)? 如何从服务器(firebase)中获取和处理某些数据? For example, I have some user data in firebase and I want to fetch this data when user is signed in. Second question is - Can I manipulate DOM inside service worker? 例如,我在firebase中有一些用户数据,并且我想在用户登录时获取此数据。第二个问题是-我可以在service worker中操作DOM吗? For example I want to render div , when function calls. 例如,我想在函数调用时渲染div Is there some way to do like that? 有什么办法可以做到吗?

const renderDiv = () => {
  let div = document.createElement('div');
  div.innerHTML = 'Some text'
  document.body.appendChild(div);
}

You cannot manipulate DOM in any way from SW. 您不能以任何方式从SW操作DOM。 SW does not have any access to DOM. SW无权访问DOM。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM