ember.js – 与Ember的Widget方法

我想使用ember与widget方法(隔离组件),设置rootElement

Ember应用程序,每个应用程序都有自己的路由器和存储(如果需要).

我在http://jsfiddle.net/4xWep/2/尝试失败了
也许路由器实例之间存在干扰问题.
它具有这种小部件方法,具有不同的应用程序和路由器?

App1 = Ember.Application.create({
  rootElement: '#app1'
});

App1.ApplicationController = Ember.Controller.extend();
App1.ApplicationView = Ember.View.extend({
  templateName: 'app1-view'
})

App1.Router = Ember.Router.extend({...})

var App2 = Ember.Application.create({
    rootElement: '#app2'
});

App2.ApplicationController = Ember.Controller.extend();
App2.ApplicationView = Ember.View.extend({
  templateName: 'app2-view'
})

App2.Router = Ember.Router.extend({...})

最佳答案 问题是你的两个应用程序的路由器使用location.hash来串行化它们的状态.

您不能在同一页面中依赖于哈希路由持久性策略的两个应用程序.

我甚至会说,在我看来,你想要实现的不是经典的“小部件”,因为它们将具有复杂的状态(如每个内部的路由意愿所示)……
当然你应该多挖一点你的建筑.也许你需要的不是两个应用程序,而是小部件,或者另一方面,几个应用程序,但不能直接在同一个文档中呈现.

也许this (related?) question会有所帮助.

点赞