ember.js에서 다음과 같이 구현했습니다. 코드는 특정 지점까지 작동합니다.Ember 라우터가 Chrome 및 Safari에서 URL을 업데이트하지 않습니다.
루트 URL (예 : '/')에서 애플리케이션을 입력하면 tasks.index로 이동해야하며 변경 사항을 #/tasks를 표시하여 반영합니다.
하지만 '#/tasks'로 이동하면 'hello from index view'메시지가 표시됩니다.
Google 크롬 버전 19 및 ember.js edge를 사용하고 있습니다.
모든 도움을 주시면 대단히 감사하겠습니다.
App = Em.Application.create({});
App.IndexView = Em.View.extend({
template: Em.Handlebars.compile(
'hello world from index'
)
});
App.ShowView = Em.View.extend({
template: Em.Handlebars.compile(
'hello world from show'
)
});
App.Router = Ember.Router.extend({
location: 'hash',
rootElement: "#my-app",
enableLogging: true,
root: Ember.State.extend({
index: Ember.State.extend({
route: '/',
redirectsTo: 'tasks.index'
}),
tasks: Ember.State.extend({
route: '/tasks',
index: Ember.ViewState.extend({
route: '/',
view: App.IndexView
}),
show: Ember.ViewState.extend({
route: '/show',
view: App.ShowView
})
})
})
});
App.initialize();
좋은 소식 !!! 고맙습니다! – codehugger
내가 혼란스러워하는 것이 더 있습니다. 'tasks.show'로 리다이렉트하면 URL을 '#/tasks/show'로 업데이트하면 안됩니까? 'tasks.index'와 똑같이 동작합니다. 즉 URL이 전혀 업데이트되지 않습니다. – codehugger
레일 라우터에서 루트를 정의하는 것처럼 동작하기 때문에 그럴 것 같아요. 이제 응용 프로그램 루트는 tasks.index이고 url에 "/"을 지정하여 도달 할 수 있으므로 변경되지 않습니다. task.index 상태로 transitionTo하면 url이 바뀌기 때문에 이것이 작동하는 것을 볼 수 있습니다. –