1. 程式人生 > 程式設計 >vue中路由跳轉不計入history的操作

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的操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支援我們。