国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 網(wǎng)站 > 幫助中心 > 正文

解決vue 打包發(fā)布去#和頁(yè)面空白的問(wèn)題

2024-07-09 22:40:11
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
今天小編就為大家分享一篇解決vue 打包發(fā)布去#和頁(yè)面空白的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

1.vue項(xiàng)目中config文件下index.js中打包配置

build: { // Template for index.html index: path.resolve(__dirname, '../yiTownWebApp/index.html'), // Paths assetsRoot: path.resolve(__dirname, '../yiTownWebApp'), assetsSubDirectory: 'static', assetsPublicPath: '/yiTownWebApp/',//這個(gè)地方使用絕對(duì)路徑很重要 /** * Source Maps */ productionSourceMap: true, // https://webpack.js.org/configuration/devtool/#production devtool: '#source-map', // Gzip off by default as many popular static hosts such as // Surge or Netlify already gzip all static assets for you. // Before setting to `true`, make sure to: // npm install --save-dev compression-webpack-plugin productionGzip: false, productionGzipExtensions: ['js', 'css'], // Run the build command with an extra argument to // View the bundle analyzer report after build finishes: // `npm run build --report` // Set to `true` or `false` to always turn it on or off bundleAnalyzerReport: process.env.npm_config_report}

2.路由配置:router文件夾下index.js

export default new Router({ mode: 'history',//去掉#, base: '/yiTownWebApp/',//這個(gè)配置也很重要,否則會(huì)出現(xiàn)頁(yè)面空白情況 scrollBehavior: () => ({ y: 0 }), routes: [ { path: '/article', name: 'article', component: article }, { path: '/footMark', name: 'FootMark', component: FootMark }, { path: '/shareFootMark', name: 'ShareFootMark', component: ShareFootMark } ]})

nginx配置:

 server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; #打包后的項(xiàng)目目錄,一定記住這個(gè)地方帶有項(xiàng)目名稱 root /Users/a123/Desktop/vue/sgAdmin/yiTownWebApp; index index.html; location /yiTownWebApp{  #這個(gè)地方?jīng)]有項(xiàng)目名稱,因?yàn)檎?qǐng)求的時(shí)候如果請(qǐng)求:http://localhost:8080/yiTownWebApp,nginx會(huì)查找/Users/a123/Desktop/vue/sgAdmin/yiTownWebApp/目錄下的數(shù)據(jù)  root /Users/a123/Desktop/vue/sgAdmin;  try_files $uri $uri/ @router;  index index.html; } //try_files $uri $uri/ @router;和下邊部分很重要,沒(méi)有這部分發(fā)布二級(jí)一下的路由會(huì)出現(xiàn)js加載,但是也沒(méi)空白的情況 location @router {  rewrite ^.*$ /index.html last; } }

以上這篇解決vue 打包發(fā)布去#和頁(yè)面空白的問(wèn)題就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持武林網(wǎng)之家。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 伊宁县| 定州市| 易门县| 山阴县| 台州市| 偃师市| 甘洛县| 赫章县| 鄢陵县| 宁夏| 公主岭市| 南和县| 遂平县| 泰安市| 阿瓦提县| 隆林| 嵊州市| 桦川县| 呼玛县| 黄骅市| 胶南市| 合水县| 临西县| 突泉县| 简阳市| 玉山县| 秦皇岛市| 六盘水市| 韶关市| 江安县| 行唐县| 安福县| 赫章县| 安宁市| 琼海市| 林甸县| 浦东新区| 曲麻莱县| 雅江县| 静安区| 淅川县|