首页 > 编程语言 > vue中路由跳转不计入history的操作
2020
10-10

vue中路由跳转不计入history的操作

我就废话不多说了,大家还是直接看代码吧~

 <van-field
  label="选择部门"
  :value="arr.DepartMentName"
  readonly
  right-icon="arrow"
  @click="$router.replace({ name: 'tree' })"
  />

在下个页面使用replace跳回来即可

补充知识:vue-router模式为history的项目打包发布后不能通过地址栏里的地址进行路由跳转

项目打包发布后不能通过地址栏里的地址进行路由跳转,地址栏里回车访问就直接404

本项目使用nginx发布,所以这里只有nginx的配置方式。

修改nginx的配置文件

server {
  listen  8080;
  server_name localhost;
  #charset koi8-r;
  #access_log logs/host.access.log main;
  location / {
   try_files $uri $uri/ /index.html;#必须要有的
   root /home/dist/;#打包后的项目路径,index.html所在文件夹
   index index.html index.htm;
  }
}

以上这篇vue中路由跳转不计入history的操作就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持自学编程网。

编程技巧