vue-router改写一下导入路由

const getImport = (file, path) => require(`@/${path || 'views'}/` + file + '.vue').default
{path: '/getAddressList', name: 'getAddressList', component: getImport('configCenter/formList')},
{path: '/getAddressDetail', name: 'getAddressDetail', component: getImport('configCenter/getAddress')}

这么写单纯的是为了不用每次都import那个路径,原理就看看require和import的区别就是了,记住看.default

你可能感兴趣的:(随笔&笔记)