angular.js - webpack 能實(shí)現(xiàn) angular-router 懶加載嗎?
問題描述
webpack打包了一個(gè)主js 然后打包成2個(gè)單獨(dú)的js 但是路由變化的時(shí)候 沒有加載這個(gè)路由的js求指教?
#core.router.jsimport LoginRouter from ’bundle?lazy!../states/login/login.route’import IndexRouter from ’bundle?lazy!../states/index/index.route’function CoreRouter($routeProvider,$locationProvider) { $routeProvider.when(’/’,IndexRouter).when(’/login’,LoginRouter).otherwise({redirectTo: ’/’});}CoreRouter.$inject = [’$routeProvider’,’$locationProvider’];export default CoreRouter;
下面是核心加載模塊
#code.module.jsimport $ from ’jquery’import ’angular-animate’import ’angular-route’;import ’angular-resource’import ’angular-cookies’import ’../../lib/toaster/toaster.min’import ’../../service/service.module’import ’../..//components/components.module’import ’../..//filter/filter.module’import ’../../service/ApiConfig’import ’../../components/loading/http-loading’;import LoginModule from ’../states/login/login.module’import IndexModule from ’../states/index/index.module’//router核心模塊最后加載import CoreRouter from ’./core.router’ //加載上面的核心路由模塊var CoreModule = angular.module(’cm.bg’,[ ’ngRoute’, ’ngCookies’, ’ngResource’, ’ngAnimate’, ’cm.filter’, ’cm.components’, ’cm.service’, ’toaster’, LoginModule.name,IndexModule.name,]) .config(CoreRouter) .run([’$rootScope’, function($rootScope){}]);export default CoreModule
問題解答
回答1:使用 ocLazyLoad 實(shí)現(xiàn)懶加載
相關(guān)文章:
1. MySQL 使用 group by 之后然后 IFNULL(COUNT(*),0) 為什么還是會(huì)獲得 null2. wordpress里,這樣的目錄列表是屬于小工具還是啥?3. 我的怎么不顯示啊,話說(shuō)有沒有QQ群什么的4. mysql 為什么主鍵 id 和 pid 都市索引, id > 10 走索引 time > 10 不走索引?5. 常量在外面不加引號(hào)會(huì)報(bào)錯(cuò)。6. 一直報(bào)這個(gè)錯(cuò)誤7. mysql federated引擎無(wú)法開啟8. python如何設(shè)置一個(gè)隨著系統(tǒng)時(shí)間變化的動(dòng)態(tài)變量?9. mysql - 大部分?jǐn)?shù)據(jù)沒有行溢出的text字段是否需要拆表10. sublime text3安裝package control失敗
