我使用dot net core with angular 4和webpack config.
当我试图在组件或服务中获取窗口或文档时,我收到此错误:
ReferenceError:未定义文档
ReferenceError:未定义窗口
以下是我得到的错误:
Microsoft.AspNetCore.NodeServices[0]
ERROR { ReferenceError: window is not defined
at _window (C:\gitRepose\AngularCore\FM\FMWebApp\FootballWebApp\ClientApp\dist\main-server.js:30801:12)Run Code Online (Sandbox Code Playgroud)
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: window is not defined
ReferenceError: window is not defined
at _window (C:\gitRepose\AngularCore\FM\FMWebApp\FootballWebApp\ClientApp\dist\main-server.js:30801:12)Run Code Online (Sandbox Code Playgroud)
我仍然是webpack的新手,有谁知道我可以解决这个问题?当窗口调整大小时,我需要窗口来处理.
编辑...
我设法通过从index.cshtml中删除预渲染来解决这个问题
我改变了这个:
<app asp-prerender-module="ClientApp/dist/main-server">Loading...</app>
Run Code Online (Sandbox Code Playgroud)
对此:
<app>Loading...</app>
Run Code Online (Sandbox Code Playgroud)
但现在很明显在服务器端预渲染不会发生:/因此它会减慢应用程序启动时间,任何想法如何解决这个问题而不会丢失服务器端预渲染?
我安装xamarin在Mac和遵循的指示在这里允许远程登录(这样我可以在我的Windows机器上使用模拟器),我是能够通过MAC代理时,我跑我得到这个错误连接没有问题,但是:
想知道你们有没有这些问题吗?
当我在我的MAC上的xamarin工作室中创建一个解决方案并在MAC上运行应用程序时它没有出现任何错误...任何可能有帮助的想法?
MAC更新日志:
[2016-06-22 15:25:21.5] PERF: - Bridge loaded in 358.017ms
[2016-06-22 15:25:21.5] PERF: Total time for bootstrapping process: 413ms
[2016-06-22 15:25:21.5] ERROR: com.xamarin.MTHosting.cb5bcd1: InstallAndLaunch (attempt 3): System.IO.DirectoryNotFoundException: /Users/Christian Agius/Library/Caches/Xamarin/mtbs/builds/DAAppiOS/6a5cceef9b57993d401c68f8154370ef/bin/iPhoneSimulator/Debug/DAAppiOS.app
at MonoTouch.Hosting.Session.InstallApplication (System.String bundlePath) <0x87438e0 + 0x00213> in <filename unknown>:0
at MonoTouch.Hosting.Session.InstallAndLaunch (System.String appBundlePath, System.String[] appArgs) <0x87435e8 + 0x00047> in <filename unknown>:0
[2016-06-22 15:25:21.5] ERROR: com.xamarin.MTHosting.cb5bcd1: InstallAndLaunch (attempt 4): System.IO.DirectoryNotFoundException: /Users/Christian Agius/Library/Caches/Xamarin/mtbs/builds/DAAppiOS/6a5cceef9b57993d401c68f8154370ef/bin/iPhoneSimulator/Debug/DAAppiOS.app
at MonoTouch.Hosting.Session.InstallApplication (System.String bundlePath) <0x87438e0 + 0x00213> in <filename unknown>:0
at MonoTouch.Hosting.Session.InstallAndLaunch (System.String appBundlePath, System.String[] appArgs) <0x87435e8 …Run Code Online (Sandbox Code Playgroud)