首页 > 其他 > 详细

vue-router history 使用

时间:2021-04-24 12:20:20      阅读:22      评论:0      收藏:0      [点我收藏+]

1. 修改router/index.js 

  mode: "history"

  base: "page"   // 打包后放到服务器上,  域名后面的目录 127.0.0.1/page/index.html

2. 修改vue.config.js 

  publicPath: ‘/page/‘

 

3. 基于Apache服务配置文件修改

 /conf/httpd.conf   开启rewrite_module

  a. 找到 LoadModule rewrite_module libexec/apache2/ mod_rewrite.so  去掉#, 打开注释

    一般搜索 mod_rewrite.so ,  红色部分有的版本有,有的没有

  b. 找到 AllowOverride None    修改为   AllowOverride All    来使.htaccess 文件生效

4. 在127.0.0.1/page/  目录下添加.htaccess文件

  <IfModule mod_rewrite.c>
          RewriteEngine On
        RewriteBase /
        RewriteRule ^index\.html$ - [L]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . /page/index.html [L]
      </IfModule>

最后一行  ./page/  域名后面的目录

vue-router history 使用

原文:https://www.cnblogs.com/shenjilin/p/14696363.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!