간단한 라우터를 정의하고 인스턴스화했습니다.backbone.js 라우터가 URL 조각에 응답하지 않습니다.
문제점 : URL http://localhost/backbone1/#photos/5
에 갈 때, 나는 자바 스크립트 콘솔 console.log()
의 출력을 볼 것으로 예상하지만, 아무것도가 표시되지 않습니다. 내가 뭔가 놓친거야?
JS 코드
var GalleryRouter = Backbone.Router.extend({
routes: {
"about": "showAbout",
"photos/:id": "getPhoto",
"search/:query": "searchPhotos",
"search/:query/p:page": "searchPhotos",
"photos/:id/download/*imagePath": "downloadPhoto",
"*other": "defaultRoute"
},
showAbout: function() {
},
getPhoto: function(id) {
console.log('You are trying to reach photo ' + id);
},
searchPhotos: function(query, page) {
console.log('Page number: ' + page + ' of the results for ' + query);
},
downloadPhoto: function(id, imagePath) {
},
defaultRoute: function(other) {
console.log("Invalid. You attempted to reach: " + other);
}
});
var myGalleryRouter = new GalleryRouter();