2016-08-31 8 views
0

"/ b"경로에서 내 백본 앱을 제공해야하고 라우터에 연결하는 데 문제가 있습니다. 그것은 단지보기를 보여 주면 잘 작동하지만, 내 라우터에 연결했을 때 내 루트 컨트롤러 기능이 작동하지 않습니다.마리오 네트 라우터가 아닌 인덱스 루트 경로

라우터 (발사 확인)

define('appRouter', ['marionette', 'rootView', 'changePasswordView'], function(Marionette, rootView, changePasswordView) { 
    return Marionette.AppRouter.extend({ 
    routes: { 
     '/b/change-password': 'showChangePassword', 
     '/b': 'showAccountSettings' 
    }, 
    showChangePassword: function() { 
     this.showView(new changePasswordView()); 
    }, 
    showAccountSettings: function() { 
     this.showView(new rootView()); 
    } 
    }); 
}); 

애플리케이션 ONSTART :

var Application = Marionette.Application.extend({ 

... 

    onStart: function(options) { 
     console.log('on start'); 
     var router = new appRouter(options); 
     /** Starts the URL handling framework */ 
     if(! Backbone.History.started) Backbone.history.start(); 
     router.initialize(); 
    }, 

... 

}); 

내가 방문 할 때 http://localhost:8080/b (내 인덱스 모든 집중적 인 목적이다)는 빈 페이지를 렌더링합니다.

+0

당신이 당신의 Marionette.Application의 경로를 등록을? 그 코드를 게시 할 수 있습니까? –

+0

그게 내가 누락 된 것일 수도 있습니다. onStart는'''Application = Marionette.Application.extend ({...})''클래스 확장 – goofiw

답변

1

백본의 기본 경로는 hash-based입니다. /b 경로로 연결되는 링크는 http://localhost:8080/#/b이어야합니다.

해시 기반 링크가 필요하지 않으면 pushState: true으로 시작 기록을 시작하십시오.

Backbone.history.start({pushState: true}); 

편집 : 당신은 /b 경로에 응용 프로그램을 제공하는 경우

, 다음, 당신이 잘못 정의 경로. 경로는 /b에 상대적으로 정의해야합니다

routes: { 
    'change-password': 'showChangePassword', 
    '': 'showAccountSettings' 
}, 

및 액세스 :

  • http://localhost:8080/b' - showAccountSettings`
  • http://localhost:8080/b#change-password' - showChangePassword`
+0

에 있습니다. 앱은 '/ b' 경로가 아니라 '/'경로. '/ b'전에는 액세스 할 수 없으며 액세스 할 수도 없습니다. – goofiw

+0

감사합니다. – goofiw