EmberJs错误中的Hello World

时间:2016-07-29 07:36:35

标签: javascript model-view-controller ember.js

我在 EmberJs 中编写第一个程序作为"Hello World"打印,但收到错误。有人可以帮我吗?

HTML

<html>
<head>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.7.0/ember.min.js"></script>
    <script>
      App = Ember.Application.create();
      App.Router.map(function() {
        this.resource('index', { path: '/' }, function() {});
        this.resource('hi', { path: '/hi' }, function() {});
      });
    </script>
    <script type="text/x-handlebars" data-template-name='index'>
      <p>index!</p>
      <p>{{#linkTo hi}}hi{{/linkTo}}</p>
    </script>
    <script type="text/x-handlebars" data-template-name='hi'>
      hello world!
    </script>
</head>
<body>
</body>
</html> 

错误

enter image description here

1 个答案:

答案 0 :(得分:1)

您需要包含ember-template-compiler而不是把手:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.7.0/ember.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ember.js/2.7.0/ember-template-compiler.js"></script>

你也不能使用linkTo助手,因为它已被弃用,这就是你得到另一个错误的原因。这是working fiddle.