angular.js - webpack 能实现 angular-router 懒加载吗?
问题描述
webpack打包了一个主js 然后打包成2个单独的js 但是路由变化的时候 没有加载这个路由的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 实现懒加载
相关文章:
1. 如图,java中同样是utf-8存储的字符串,为什么这两种方式输出的字节会不同?2. javascript - ElementUI tree控件怎么通过子节点去找到父节点?3. linux - python ImportError: No module named ’***’4. mongodb可以导出数据到excel吗?5. python - 一个简单的正则匹配问题6. Android的webView如何实现网页 录音功能?7. Python 中如何对单个字典中同一个 key 的值进行合并?8. python 中文乱码问题9. 使用Python如何抓取APP中的数据?10. python - win7 64位,安装urllib老是报错?

网公网安备