javascript - 为什么 ember serve 与 index.html 的行为不同?

标签 javascript html ember.js ember-cli

我正在使用 ember-cli 0.0.33

我使用以下方法创建了一个默认应用

ember new stealth

然后我用

构建了它
ember build --environment=production

然后我将 index 文件上传到 https://d1mungh8jer63d.cloudfront.net/index.html 并将 asset 文件上传到 ../assets/* 然后在 ChromeFirefox 中打开 index url 并在两者上都出现空白屏幕.

接下来,不做任何改变,我跑了

ember s --environment=production --live-reload=false

这给了我完全相同的 dist 文件。我将浏览器打开到 localhost:4200,页面上有 Welcome to Ember.js

但是 index.htmllocalhost:4200 都有相同的来源:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Stealth</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <base href="/" />

    <link rel="stylesheet" href="https://d1mungh8jer63d.cloudfront.net/assets/vendor-d41d8cd98f00b204e9800998ecf8427e.css">
    <link rel="stylesheet" href="https://d1mungh8jer63d.cloudfront.net/assets/stealth-de3c495d5da3bffcdc865aaa60f76ab3.css">
  </head>
  <body>
    <script>
      window.StealthENV = {"baseURL":"/","locationType":"auto","EmberENV":{"FEATURES":{}},"APP":{}};
      window.EmberENV = window.StealthENV.EmberENV;
    </script>
    <script src="https://d1mungh8jer63d.cloudfront.net/assets/vendor-5429f75166356b28c3e42dd401abaf36.js"></script>
    <script src="https://d1mungh8jer63d.cloudfront.net/assets/stealth-271c63d147abd689113e3c0bae25a9e5.js"></script>
    <script>
      window.Stealth = require('stealth/app')['default'].create(StealthENV.APP);
    </script>
  </body>
</html>

为什么一个“工作”/显示Welcome to Ember.js,而另一个只显示空白屏幕?以及如何使 index.html“工作”?

最佳答案

(OP能够解决他自己的问题。我只是在这里粘贴他自己的答案,所以可以找到)

如果需要将 ember 项目部署到子目录,请使用 baseUrl配置。

关于javascript - 为什么 ember serve 与 index.html 的行为不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24173848/

相关文章:

javascript - 我怎样才能通过使用 HTML、CSS 和 JavaScript 来实现这样的效果(参见内部)?

javascript - NodeJS - 无限调用 promise 函数

ember.js - 刷新页面后 ember-simple-auth session.isAuthenticated 为 false

ember.js - Ember.js 框架的状态如何?

javascript - 随机图像 slider (JS)

javascript - Promise 不会等待 for 循环完成

javascript - 仅删除特定 Div Id

html - 我的文本区域干扰了表格中的其他 td 元素

jquery - 为什么我的下拉菜单链接不起作用

javascript - Ember - 嵌套 View 中的异步数据