骨干网的要求如何适用于我的案例

how backbone requirejs works for my case?

本文关键字:适用于 我的 案例 骨干网      更新时间:2023-09-26

我正在构建一个使用需求和骨干的应用程序,我想在一些动作后异步加载模块。

假设我有一些模块,比如

authentication
module1
module2
module3
module4
platform
utils

最初我需要加载身份验证模块,成功后

我想加载特定的模块(视图,模型,集合)基于路由使用需求。

我如何加载模块解释?

请告知,这个图案是否有样板?

如果您使用的是木偶模块:

在模块中可以使用

startWithParent = false

然后在所需的路由中启动模块

例如你有定义为

的路由
appRoutes: {
        'login': 'login'
}

在控制器

login: function(){
       // you can require the login module here
      // if you using backbone only you can require views, models, collections in the       
      //similar way in the desired routes
      require(['modules/LoginModule'], function(LoginModule) {
            App.module('LoginModule').start();
      });
}

当你想停止模块

 App.module('LoginModule').stop();