我正在使用 ember-cli 0.0.33
我使用以下方法创建了一个默认应用
ember new stealth
然后我用
构建了它ember build --environment=production
然后我将 index
文件上传到 https://d1mungh8jer63d.cloudfront.net/index.html
并将 asset
文件上传到 ../assets/*
然后在 Chrome
和 Firefox
中打开 index
url 并在两者上都出现空白屏幕.
接下来,不做任何改变,我跑了
ember s --environment=production --live-reload=false
这给了我完全相同的 dist
文件。我将浏览器打开到 localhost:4200
,页面上有 Welcome to Ember.js
。
但是 index.html
和 localhost: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/