qinshenxue / vue2-vue-router2-webpack2

《从零搭建 vue2 vue-router2 webpack4 工程》《从零搭建 vue2 vue-router2 webpack3 工程》《搭建 vue2 vue-router2 webpack3 多入口工程》
MIT License
91 stars 23 forks source link

老司机mpa1的路由不支持history模式?? #3

Closed zuoye520 closed 7 years ago

zuoye520 commented 7 years ago

http://localhost:8080/web.html#/css

需要支持history模式怎么解决?

qinshenxue commented 7 years ago

已增加分支 mpa1-history-mode-router

关键配置:

// dev.js
historyApiFallback: {
        rewrites: [
            { from: /^\/web/, to: '/web/index.html' },
            { from: /^\/admin/, to: '/admin/index.html' }
        ]
    }
// web/router.js
{
    base: process.env.NODE_ENV === "production" ? '/' : '/web/',
    mode: 'history',
}
// admin/router.js
{
    base: process.env.NODE_ENV === "production" ? '/' : '/admin/',
    mode: 'history',
}