javascript Angularjs 应用程序在 Chrome 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23252117/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Angularjs application not working in chrome
提问by Shekkar
A simple application of route manager of AngularJs is not working in a chrome, but it is fine in fire fox. My code is here http://plnkr.co/edit/WIdRx1FTQ9HeZNkVPz74?p=preview, when we try to place index , homePage, script files in local , it is not working in chrome . I got error message in chrome console as No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access
. So what changes have to be made in my code to satisfy chrome.
AngularJs 的路由管理器的一个简单应用在 chrome 中不起作用,但在 fire fox 中很好。我的代码在这里http://plnkr.co/edit/WIdRx1FTQ9HeZNkVPz74?p=preview,当我们尝试将 index 、 homePage 、 script 文件放在 local 中时,它在 chrome 中不起作用。我在 chrome 控制台中收到错误消息为 No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access
. 那么我的代码需要做哪些改动才能满足 chrome.
采纳答案by JSager
The issue is not with AngularJS. Please check here for the answer to your problem: Origin is not allowed by Access-Control-Allow-Origin
问题不在于 AngularJS。请在此处查看问题的答案:Access-Control-Allow-Origin 不允许使用 Origin
回答by Puneet Mahendra
Some browsers like Chrome do not allow cross-origin on file://
某些浏览器(如 Chrome)不允许跨域文件://
Make sure you are running the application from a local server(like Wamp)
确保您从本地服务器(如 Wamp)运行应用程序
Then it will work
然后它会工作