您的位置:首页 > Web前端 > Vue.js

vue-router改写一下导入路由

2019-01-03 19:18 211 查看
版权声明:只能用于学习 https://blog.csdn.net/qq_33559093/article/details/85713628
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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: