【发布时间】:2018-03-10 05:44:28
【问题描述】:
我正在使用 asp.net core 2.0 AngularJS 模板,当我尝试在 AppComponent 中使用 localStorage 时显示
NodeInvocationException: localStorage 未定义 ReferenceError: localStorage 未定义。
我浪费了很多时间来解决这个问题,不幸的是 angular2-universal 甚至没有使用 asp.net core 2.0 来检查条件 isBrowser。事件 localStorage 也不能与 HomeComponent 一起使用。
我该如何解决这个问题。请帮我解决这个问题。谢谢。
export class AppComponent {
constructor() {
localStorage.setItem('count', 'not set');
console.log('const');
}
}
【问题讨论】:
-
这并没有解决我的问题。实际上我可以在 CounterComponent 和 FetchDataComponent 中使用 localStorage。只有 HomeComponent 和 AppComponent 在我的模板中才会发生。
-
我也有类似的问题。我注释掉了所有本地存储代码并再次运行 Web 应用程序,然后我得到了一个不同的错误。
NodeInvocationException: The Node invocation timed out after 60000ms. You can change the timeout duration by setting the InvocationTimeoutMilliseconds property on NodeServicesOptions. The first debugging step is to ensure that your Node.js function always invokes the supplied callback (or throws an exception synchronously), even if it encounters an error. Otherwise, the .NET code has no way to know that it is finished or has failed.
标签: angularjs