webpack ,require.ensure配合oclazyload 实现ng1模块懒加载
程序员文章站
2022-07-14 20:41:58
...
import angular from 'angular'
import 'angular-ui-router'
import 'oclazyload'
import 'bootstrap/dist/css/bootstrap.min.css'
import AppComponent from './app.component'
angular.module('app', [
'ui.router',
'oc.lazyLoad',
])
.config(($stateProvider, $urlRouterProvider) => {
$urlRouterProvider.otherwise('/')
$stateProvider.state('search', {
url: '/search',
component: 'searchpageComponent',
lazyLoad:function($q, $ocLazyLoad) {
let deferred = $q.defer()
require.ensure(['./searchPage/searchpage.js'], function() {
let module = require('./searchPage/searchpage.js')
$ocLazyLoad.load({
name: 'searchPage'
})
deferred.resolve(module)
})
return deferred.promise
}
})
})
.component('appCom', AppComponent)
转载于:https://my.oschina.net/boogoogle/blog/1507382
推荐阅读
-
详解AngularJS通过ocLazyLoad实现动态(懒)加载模块和依赖
-
webpack ,require.ensure配合oclazyload 实现ng1模块懒加载
-
react-router4 配合webpack require.ensure 实现异步加载
-
react-router4 配合webpack require.ensure 实现异步加载的示例
-
Angular ui-roter 和AngularJS 通过 ocLazyLoad 实现动态(懒)加载模块和依赖
-
react-router4 配合webpack require.ensure 实现异步加载(详细教程)
-
详解AngularJS通过ocLazyLoad实现动态(懒)加载模块和依赖
-
react-router4 配合webpack require.ensure 实现异步加载
-
react-router4 配合webpack require.ensure 实现异步加载的示例
-
react-router4 配合webpack require.ensure 实现异步加载