關於vue和springboot項目的應用上下文和端口配置


  • 端口配置:
    vue項目config目錄下的index.js中port行改為你想要的端口號,注意該行后面有注釋:“can be overwritten by process.env.PORT, if port is in use, a free one will be determined”,vue項目運行時能自行決定能運行的空閑的端口號
  • 應用上下文配置:
    在項目下建一個vue.config.js文件,設置文件中publicPath行值為(比如,“/mac/”),就設置了應用上下文,在npm run dev之后可以訪問http://localhost:port/mac/路徑。
    如果你不想要路徑中有井號(“#”),在src/router/index.js中設置router的mode為"history",代碼實例如下
const router = new VueRouter({
    mode: 'history',
    routes: routes
})

springboot項目的配置可以在application.yml中做出來

server:
  port: 8081
  servlet:
    context-path: /map/

參考鏈接

1

配置參考-vue.config.js-publicPath

2

vue地址去掉 #


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM