2
/app.js
var Welcome = Ember.Application.create({});
Welcome.person = Ember.View.extend({
personName: 'Andrew'
});
這裏是index.html的內容,該視圖的一部分:Ember.js:車把顯示任何
/index.html
<!doctype html>
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script type="text/x-handlebars">
{{personName}}
</script>
<script src="js/libs/handlebars-1.0.0.beta.6.js"></script>
<script src="js/libs/ember-1.0.pre.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>
我的問題是爲什麼沒有顯示什麼?它不應該渲染personName
的內容嗎?
UPDATE:
我使用從灰燼入門工具包。它已經定義了一個視圖。我只是向對象添加了一個屬性,但仍然對視圖不可見。
App.MyView = Em.View.extend({
mouseDown: function() {
window.alert("hello world!");
},
name: 'Andrew'
});
而且以html視圖部分是:
<script type="text/x-handlebars">
{{#view App.MyView}}
<h1>Hello world {{name}}!</h1>
{{/view}}
</script>
由於該事件的作品,是不應該訪問的名字嗎?
請參閱我的更新。 – Andrew 2012-08-05 17:29:50
更新回答:) – 2012-08-05 17:49:26
現在它的工作原理:D謝謝 – Andrew 2012-08-05 18:10:18