首页 文章

ember-cli ember build生成不完整的index.html?

提问于
浏览
0

我正在尝试使用ember-cli构建一个ember应用程序 . 我使用 ember new HelloWorld 创建了应用程序并使用 ember build 构建了它 . 在"dist" -Folder里面是一个带有此标记的index.html:

<!DOCTYPE html>
  <html>
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <title>HelloWorld</title>
      <meta name="description" content="">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <base href="/" />
      <meta name="hello-world/config/environment" content="..." />
      <link rel="stylesheet" href="assets/vendor.css">
      <link rel="stylesheet" href="assets/hello-world.css">    
    </head>
    <body>
      <script src="assets/vendor.js"></script>
      <script src="assets/hello-world.js"></script>    
    </body>
  </html>

在较旧的Ember-Versions中,我们在index.html中编写了模板 . 我现在知道模板,但它们在哪里?当我用浏览器打开index.html时,我得到一个空页面 . 这怎么工作?我们是否需要为ember-app运行节点服务器?我只想在Asp.Net项目中复制 ember build 的输出,并将文件包含到我的index.cshtml中 .

1 回答

  • 0

    在较旧的Ember-Versions中,我们在index.html中编写了模板 . 我知道ember现在“预编译”模板,但它们在哪里?

    index.html 位于 app/index.html . 其余模板位于 app/templates/ .

    当我用浏览器打开index.html时,我得到一个空页面 . 这怎么工作?

    您应该在控制台中出错:

    file:///assets/vendor.css Failed to load resource: net::ERR_FILE_NOT_FOUND
    file:///assets/appName.css Failed to load resource: net::ERR_FILE_NOT_FOUND
    file:///assets/vendor.js Failed to load resource: net::ERR_FILE_NOT_FOUND
    file:///assets/appName.js Failed to load resource: net::ERR_FILE_NOT_FOUND
    

    它's because you don'有任何服务器可以提供这个资产 . 直接通过浏览器打开 dist/index.html 将无法成功 . 您需要设置简单的Python服务器或复制资产以更正ASP.NET应用程序中的目录 . 它应该正确地公开您的Ember应用程序的资产路径 .

    我只想在Asp.Net项目中复制ember构建的输出,并将文件包含到我的index.cshtml中 .

    做吧 . 将资产放在正确的文件夹中,将 index.html 内容复制到 .cshtml 文件中 .

    但是,我想你的方法是行不通的 . 如果你想将ASP.NET应用程序与Ember集成,混合文件等,你应该在ASP.NET文件中自己包含Ember库,然后使用全局变量编写代码( App.IndexController 等) .

相关问题