简体   繁体   English

Angular 在 Chrome 中不起作用

[英]Angular does not work in Chrome

I have created an Angular-cli project in WebStorm and when I run the project by click on Run icon I can see my project in http://127.0.0.1:4200/ or http://localhost:4200/ but when I copy these links into Chrome I can not see my project and it seems that the Chrome browser does not work.我在 WebStorm 中创建了一个 Angular-cli 项目,当我通过单击运行图标运行该项目时,我可以在http://127.0.0.1:4200/http://localhost:4200/看到我的项目,但是当我复制时这些链接到 Chrome 我看不到我的项目,似乎 Chrome 浏览器不起作用。 I see all related pages but I could not find a solution.我查看了所有相关页面,但找不到解决方案。

Do this...做这个...

run your app using 'ng serve'使用“ng serve”运行您的应用

if the app is not opened on browser如果应用程序未在浏览器上打开

load the app using http://127.0.0.1:4200/使用http://127.0.0.1:4200/加载应用程序

Enter ctrl+shift+i to open the browser console check whether there is an error if found debug it from your app.输入 ctrl+shift+i 打开浏览器控制台检查是否有错误,如果发现从您的应用程序调试它。

if it is not work try with bellow如果它不起作用,请尝试使用波纹管

you may install cors plugin from chrome web store and active cros origin resorce sharing and re-try.您可以从 chrome 网上商店安装cors 插件激活 cros 源资源共享并重新尝试。

best wishes.最好的祝愿。

I have the same issue.我有同样的问题。 After running ng serve and open web page in Chrome it displays:运行 ng serve 并在 Chrome 中打开网页后,它显示:

This page isn't working.

In Edge the application works normally.在 Edge 中,应用程序正常工作。

Even in IE 11 I get response and display but Chrome somehow ...即使在 IE 11 中,我也会得到响应并显示,但 Chrome 不知何故......

Added:添加:

Ok I've managed to find a workaround for Chrome.好的,我设法找到了 Chrome 的解决方法。 When using http://localhost:4200 in Chrome it won't work.在 Chrome 中使用http://localhost:4200时它不起作用。 But using 127.0.0.1:4200 works,但是使用 127.0.0.1:4200 有效,

where 127.0.0.1 is loop back address.其中 127.0.0.1 是环回地址。

Added:添加:

After some experimenting it appears to be Chrome extension problem.经过一些试验,它似乎是 Chrome 扩展程序的问题。 Because when I opened the page in incognito mode then it worked in Chrome as well.因为当我以隐身模式打开页面时,它也可以在 Chrome 中运行。

Use your local IP address instead of local host.使用您的本地 IP 地址而不是本地主机。 It worked for me ex: http://10.0.1.30:4200它对我有用,例如: http : //10.0.1.30 : 4200

In addition to the solution methods above, the beginning of the applicationUrl can also be checked if it is http or https caused from auto conversion by the browser.除了上面的解决方法,还可以检查applicationUrl的开头是浏览器自动转换导致的http还是https Because Google Chrome might attempt to connect to HTTPs, but there is no need to enable HTTPs for IIS Express settings.因为 Google Chrome 可能会尝试连接到 HTTPs,但不需要为 IIS Express 设置启用 HTTPs。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM