nginx 去除井号操作 2

回眸只為那壹抹淺笑 提交于 2019-12-03 21:52:26

三步走

vue-Router 路由配置

const env = (process.env.NODE_ENV && process.env.NODE_ENV.trim() === 'production');
//页面导航
export const router = new VueRouter({
  //mode: "hash",
  mode: env ? 'history' : 'hash',
  routes: [
    {
        path: '/weChat',
        component: App,
        children: [
          {
            path: 'index',
            meta: { title: '小明' },
            component: r => require.ensure([], () => r(require('weChat/batch')), 'batch'),
          }, {
            path: 'log',
            meta: { title: '小红' },
            component: r => require.ensure([], () => r(require('weChat/log')), 'log'),
          }],
        },
  ]
});

Webpack 打包配置

const env = (process.env.NODE_ENV && process.env.NODE_ENV.trim() === 'production');

output: {
	publicPath: env ? '/weChat/' : '',
},

nginx 配置

#2018-10-16
location ~ ^/weChat/[\w/]+$ {
	try_files $uri $uri/ /weChat/index.html;
}

访问地址:

开发(dev)访问:http://localhost:9000/weChat/home/omdex

打包(build)访问:http://localhost:9000/#/weChat/home/index

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!