发生了奇怪的事情。似乎文档对象不存在。当我只保存代码并单击返回浏览器时,它可以正常工作。为什么按F5键时文件不见了?
let x = this.cookieService.get("UserID");
console.log("x= " + x);
处理请求时发生未处理的异常。
NodeInvocationException:未捕获(承诺):ReferenceError:未定义文档
ReferenceError:未定义文档
在CookieService.get [以cookieString形式](C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:10652:13)
在CookieService._cookieReader(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:10751:40)
在CookieService.get(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:10670:21)
在新的HomeComponent上(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:16948:36)
在createClass(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:21881:26)
在createDirectiveInstance(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:21699:37)
在createViewNodes上(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:23127:49)
在createRootView(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:23022:5)
在Object.createProdRootView [作为createRootView]处(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:23707:12)
在ComponentFactory_.module.exports.ComponentFactory_.create(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:20813:46)
错误:未捕获(承诺):ReferenceError:未定义文档
ReferenceError:未定义文档
在CookieService.get [以cookieString形式](C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:10652:13)
在CookieService._cookieReader(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:10751:40)
在CookieService.get(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:10670:21)
在新的HomeComponent上(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:16948:36)
在createClass(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:21881:26)
在createDirectiveInstance(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:21699:37)
在createViewNodes上(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:23127:49)
在createRootView(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:23022:5)
在Object.createProdRootView [作为createRootView]处(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:23707:12)
在ComponentFactory_.module.exports.ComponentFactory_.create(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:20813:46)
在resolvePromise(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:86165:31)
在resolvePromise(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:86136:17)
在C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:86213:17
在ZoneDelegate.module.exports.ZoneDelegate.invokeTask(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:85819:31)
在Object.onInvokeTask(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:14821:37)
在ZoneDelegate.module.exports.ZoneDelegate.invokeTask(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:85818:36)
在Zone.module.exports.Zone.runTask中(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:85586:47)
在排水微任务队列(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ vendor.js:85979:35)
在
在process._tickCallback(内部/进程/next_tick.js:188:7)
Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance + d__7.MoveNext()
堆栈查询Cookie标头
NodeInvocationException:未捕获(承诺):ReferenceError:未定义文档ReferenceError:未在CookieService.get上定义文档(作为cookieString)(C:\ Users \ Matt_Herb \ Downloads \ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server。 js:10652:13),位于CookieService.get(C:\ Users \ Matt_Herb \在新位置下载\ IbewSurveyTemp \ IbewSurveyTemp \ ClientApp \ dist \ main-server.js:10670:21)
最佳答案
无法在服务器端访问文档。 Cookie管理必须在浏览器端。
关于javascript - 如果我按F5键尝试使用ngx-cookie获取cookie,但未定义“文档”,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47895489/