Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 余烬JS应用程序显示空白页_Ember.js - Fatal编程技术网

Ember.js 余烬JS应用程序显示空白页

Ember.js 余烬JS应用程序显示空白页,ember.js,Ember.js,我正在创建一个简单的Ember JS应用程序,它松散地基于网站上的。然而,我似乎无法在页面上呈现任何内容。当我检查灰烬检查器时,我的路线都存在,我没有看到任何错误,因此无法立即确定问题所在 以下是html文件: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Coin</title> <link rel="stylesheet" hre

我正在创建一个简单的Ember JS应用程序,它松散地基于网站上的。然而,我似乎无法在页面上呈现任何内容。当我检查灰烬检查器时,我的路线都存在,我没有看到任何错误,因此无法立即确定问题所在

以下是html文件:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Coin</title>
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/style.css">
  <link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
  <script type="text/x-handlebars">
    <div>Hello</div>
    {{outlet}}
  </script>
  <script type="text/x-handlebars" id="accounts">
    <div>accounts</div>
    <div class="col-md-2">
        <ul class="nav nav-pills nav-stacked">
            {{#each}}
            <li>account link {{#link-to 'account' this}}{{name}}{{/link-to}}</li>
            {{/each}}
        </ul>
    </div>

    <div class="col-md-10">
        {{outlet}}
    </div>
  </script>

  <script type="text/x-handlebars" id="account">
    <ul>
      {{#each}}
      <li>{{comment}}</li>
      {{/each}}
    </ul>
  </script>

  <script src="js/libs/jquery-1.10.2.js"></script>
  <script src="js/libs/handlebars-1.1.2.js"></script>
  <script src="js/libs/ember-1.4.0.js"></script>
  <script src="js/app.js"></script>
  <script src="dist/js/bs-core.min.js"></script>
  <script src="dist/js/bs-nav.min.js"></script>
  <!-- to activate the test runner, add the "?test" query string parameter -->
  <script src="tests/runner.js"></script>
</body>
</html>
在页面上正确呈现的一件事是应用程序模板中的“Hello”。当我导航到#/accounts或任何其他已定义的路由时,{outlet}中没有显示任何内容。事实上,当我在url中添加#/accounts时,甚至我的“Hello”都消失了

有什么明显的东西我忽略了吗?我是Ember的新手,所以我肯定这有点傻,但我无法从文档中找出问题所在


编辑:我使用的是直接从网站链接的Ember v1.4.0,我在Ember Inspector中选中了“允许访问文件URL”。

我制作了一个工作版本,您在本节中开始的内容

我注意到你做错了,试图用这个
{{{#链接到'account'this}
链接到一个不存在的路由。您没有定义我注意到您希望接收参数的帐户路径。但是,我认为您希望在迭代中发送当前项的id。因此,您只需将其更改为
{{{#链接到'account'id}}

因此,有两个重要的修改是添加路由和修复助手的参数。然后我假设您也希望显示事务,并且也解决了这个问题

希望这有帮助

App = Ember.Application.create();

App.Router.map(function() {
    this.resource('accounts');
    this.resource('transactions', { path: ':accounts_id' });
})

App.AccountsRoute = Ember.Route.extend({
    model: function() {
        return accounts;
    }
})

App.TransactionsRoute = Ember.Route.extend({
    model: function() {
        return transactions;
    }
})





var accounts = [{
    id: 1,
    name: 'Account 1',
}, {
    id: 2,
    name: 'Account 2'
}];

var transactions = [{
    id: 1,
    id_account: 1,
    amount: 12,
    comment: 'blah'
}, {
    id: 2,
    id_account: 1,
    amount: 5,
    comment: 'blah2'
}, {
    id: 3,
    id_account: 2,
    amount: 98,
    comment: 'blah4'
}];