Dav*_*ang 2 ember.js ember-cli
我有以下问题.
我用ember-cli创建了一个ember应用程序.
http://localhost:4200/运行该命令时,应用程序通过url在nodejs上正常工作ember serve
我想在apache httpd服务器上部署此应用程序.
为了使这个工作,我认为它在firefox中打开时也应该是独立的.
当我在Firefox中打开它时,我收到一个错误:
要求没有定义
生成的index.html是
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Foo</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1 user-scalable=no">
<base href="/" />
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/foo.css">
</head>
<body>
<script>
window.FooENV = {"environment":"development","baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{"LOG_RESOLVER":true,"LOG_ACTIVE_GENERATION":true,"LOG_MODULE_RESOLVER":true,"LOG_VIEW_LOOKUPS":true},"LOG_MODULE_RESOLVER":true};
window.EmberENV = window.FooENV.EmberENV;
</script>
<script src="assets/vendor.js"></script>
<script src="assets/foo.js"></script>
<script>
window.Foo = require('foo/app')['default'].create(FooENV.APP);
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
谢谢,
大卫
file:///J:/assets/ndd.css
Run Code Online (Sandbox Code Playgroud)
这看起来像你只是双击你的dist文件夹中的index.html文件.这不起作用!
您必须通过http服务器为您的目录提供服务.
使用npm安装一个简单的http服务器:
npm install -g http-server
Run Code Online (Sandbox Code Playgroud)
移动到您的dist文件夹并运行http-server.您将看到如下消息:
Starting up http-server, serving ./ on port: 8080
Run Code Online (Sandbox Code Playgroud)
现在,您可以在Firefox中检查您的ember应用: http://localhost:8080
以下是在apache中正确部署Ember CLI应用程序所需执行的操作.
我们假设您要使用XAMPP.你可能会在里面创建一个文件夹htdocs并命名它myapp.ember new appname从内部运行命令时myapp,CLI生成整个项目并将其放在appname文件夹中.
现在,当您构建项目时ember build,应用程序的整个编译版本将位于:myapp\appname\dist.
由于Ember CLI使用base元标记index.html,因此您需要修改baseUrl变量myapp\appname\config\environment.js,并将其设置为myapp/appname/dist/.重建和应用程序将通过访问工作localhost/myapp/appname/dist
这是一个稍微复杂且完全不实用的文件夹结构,但它是如何工作的一个很好的例子,我相信新手会偶然发现完全相同的用例.