webpack打包了一个主js 然后打包成2个单独的js 但是路由变化的时候 没有加载这个路由的js
求指教?
#core.router.js
import 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.js
import $ 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
Use ocLazyLoad to implement lazy loading