'Angular4 web worker''ERROR not implemented'
问题描述:
我用描述here的步骤将我的Angular4应用程序转换为网络工作者。当我运行应用程序,我看到以下错误:'Angular4 web worker''ERROR not implemented'
从现有Angular4应用程序我有变化和新的一个是网络工作者的支持。
该错误没有给出任何线索,什么组件或代码是造成这种情况。有没有可以添加到某处找到导致此错误的跟踪?
---- 6/28 -----
从以下代码
WorkerDomAdapter.prototype.getCookie = function (name) { throw 'not implemented'; };
在平台webworker.umd.js生成错误UPDATE
呼叫getCookie
由http.umd.js进行。
答
这个问题的解决方案是创建一个自定义XSRFStrategy
所以角http
模块使用自定义的,而不是默认的。
import { HttpModule, XSRFStrategy, Request } from '@angular/http';
...
class CustomXSRFStrategy extends XSRFStrategy
{
public configureRequest(req: Request) { /* */ }
}
...
providers: [{ provide: XSRFStrategy, useValue: new CustomXSRFStrategy() }]
答
你不能用一个网络工作者访问饼干,以及localStorage
或sessionStorage
无法访问。
一些更多的信息,类似的问题都可以在这里找到:Accessing localStorage from a webWorker