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
使用 ocLazyLoad 實現懶加載