vue-router异步加载组件

export default {
    routes: [

    {
        path: '/fund',
        name: 'FundManagement',
        component: function(resolve) {
            resolve(require('userManage'))
        },
        children: [{
            path: '/fund/fundlist',
            name: 'FundList',
            component: function(resolve) {
                require.ensure(['fundList'], () => {
                    resolve(require('fundList'))
                });
            },
            meta: {
                menuName: '基金列表'
            }
        }, {
            path: '/fund/intelliComb',
            name: 'IntelliComb',
            component: function(resolve) {
                require.ensure(['intelliComb'], () => {
                    resolve(require('intelliComb'))
                });
            },
            meta: {
                menuName: '智能组合产品'
            }
        }, ]
    },
]}

同步:

component: function(resolve) {
     resolve(require('userManage'))
}

异步:

component: function(resolve) {
       require.ensure(['fundList'], () => {
              resolve(require('fundList'))
       });
},

 

posted on 2017-07-13 15:27  CNundefined  阅读(592)  评论(0编辑  收藏  举报