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

            }

           });

 

你可能感兴趣的:(requirejs)