[英]Yeoman angularjs build error
I install yeoman and bootstrap an angularjs project. 我安装yeoman并引导angularjs项目。
I use grunt server
command to debug and code. 我使用
grunt server
命令来调试和编码。 But when I use command 'grunt build'. 但是当我使用命令'grunt build'时。 It generates dist folder.
它生成dist文件夹。 But when I run index.html have javascript error like that:
但是,当我运行index.html时,有这样的javascript错误:
XMLHttpRequest cannot load file:///home/cuongcua/project/magic-listen/dist/views/main.html.
XMLHttpRequest无法加载file:///home/cuongcua/project/magic-listen/dist/views/main.html。 Cross origin requests are only supported for HTTP.
仅支持HTTP的跨源请求。
You can use grunt server:build
您可以使用
grunt server:build
You can't use AngularJs without server except if you enable CSP (Content Security Policy) support. 除非启用CSP(内容安全策略)支持,否则不能在没有服务器的情况下使用AngularJ。 http://docs.angularjs.org/api/ng.directive:ngCsp
http://docs.angularjs.org/api/ng.directive:ngCsp
grunt build
is use when you need to build your application and copy your dist folder on a server. 当您需要构建应用程序并在服务器上复制dist文件夹时,可以使用
grunt build
。
The simplest solution is: 最简单的解决方案是:
cd dist
python -m SimpleHTTPServer
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.