backbonejs和requirejs的實例

define(['login', 'ApplyFlapper'],  //爲ApplyFlapper爲ApplyFlapper.js文件
    function (loginView,  applyFlapperView) {   //applyFlapperView的view
        var Router = Backbone.Router.extend({
            routes: {
                '': 'showHome',
               
                'applyFlapper': 'showApplyFlapper',   //對應的是頁面applyFlapper.html,showApplyFlapper()爲打開頁面的方法
            },
            data: {
                module_login: null,
              
                module_ApplyFlapper: null,
            },
            showHome: function () {
                if (!this.data.module_auctionList) {
                    this.data.module_auctionList = new auctionListView();
                }
                this.data.module_auctionList.render();
            },
               showApplyFlapper: function () {
                console.log("go to ApplyFlapper");
                if (!this.data.module_ApplyFlapper) {
                    this.data.module_ApplyFlapper = new applyFlapperView();
                }
                this.data.module_ApplyFlapper.render();
            },
            init: true
            }
           });
相關文章
相關標籤/搜索