I am following the ember.js example on this site (http://todomvc.com/) . I clone this project to my computer and just double click index.html
and it runs, as what I expect.
But in ember's guide , it tells me to install the ember-cli, and create a new project, then build it.
ember new myapp
ember build
I can find my files in /dist
, but when I double click the index.html
it fails.
This post said, "You have to serve your directory with an http server."
Why do I need a server to run this project, instead of just opening it in my browser?
The example that you linked is using the old global Ember. This is very different from ember-cli which you are now working with. An http server is required because of the <base>
tag in the index.html
file that specifies the base URL to use for all relative URLs contained within a document. So when your app is trying to serve up the assets/app.js
or assets/vendor.js
, its trying to look relative to this base url, which is defined in config/environment.js
. It defaults to /
. So you need a server to respond to the resource requests for the assets. Notice that your assets
folder is relative to the index.html
file
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.