作用
配置
如果是基于create-react-app创建的react项目,则在src/index.js中有该功能的启用/禁用:
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
注意该配置默认只在生产环境才生效,具体见serviceWorker.js中相应方法代码