【问题标题】:Ember is only for one page website?Ember 仅适用于一页网站?
【发布时间】:2014-01-09 07:53:02
【问题描述】:
我对 Js MVC framework 很感兴趣,比如 Ember,但在很多地方。
我听说 ember 用于单页 Web 应用程序。
我有些困惑。
我可以将 ember 用于具有大量页面的大型应用程序吗?
如果我不能,那么哪个 MVC 框架最适合大型应用程序。
提出你的想法...
【问题讨论】:
标签:
javascript
jquery
ember.js
【解决方案2】:
无论有没有Ember.Router,都可以使用Ember.js。如果应用程序不需要更改浏览器的地址栏,下面将设置一个基本的、一个“页面”的 Ember 安装。
给定以下代码:
var App = Ember.Application.create({
// Append application to a selector
rootElement: '#ApplicationView'
});
App.Router = Ember.Router.extend({
// Set the default location
location: 'none'
});
App.Router.map(function() {
// Set the default path to home
this.resource('home', { path: '/' });
});
App.ApplicationRoute = Ember.Route.extend({
init: function() {
console.log("Application route initialized");
}
});
以下模板:
<script type="text/x-handlebars">
<h1>Hello World!</h1>
</script>
将被附加到我们的 HTML 页面中:
<div id="ApplicationView"></div>