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

首頁 > 編程 > JavaScript > 正文

解決vue 打包發布去#和頁面空白的問題

2019-11-19 13:03:15
字體:
來源:轉載
供稿:網友

1.vue項目中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/',//這個地方使用絕對路徑很重要 /** * 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/',//這個配置也很重要,否則會出現頁面空白情況 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; #打包后的項目目錄,一定記住這個地方帶有項目名稱 root /Users/a123/Desktop/vue/sgAdmin/yiTownWebApp; index index.html; location /yiTownWebApp{  #這個地方沒有項目名稱,因為請求的時候如果請求:http://localhost:8080/yiTownWebApp,nginx會查找/Users/a123/Desktop/vue/sgAdmin/yiTownWebApp/目錄下的數據  root /Users/a123/Desktop/vue/sgAdmin;  try_files $uri $uri/ @router;  index index.html; } //try_files $uri $uri/ @router;和下邊部分很重要,沒有這部分發布二級一下的路由會出現js加載,但是也沒空白的情況 location @router {  rewrite ^.*$ /index.html last; } }

以上這篇解決vue 打包發布去#和頁面空白的問題就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 韶关市| 察隅县| 雅安市| 两当县| 汝城县| 梓潼县| 白城市| 怀远县| 九龙县| 同德县| 图们市| 泰安市| 朝阳区| 法库县| 青阳县| 杭锦旗| 茶陵县| 黄陵县| 鄂尔多斯市| 阳东县| 化州市| 余江县| 汶川县| 赤水市| 蒲城县| 武隆县| 明星| 天等县| 睢宁县| 托里县| 临颍县| 安西县| 卓资县| 元朗区| 方城县| 盘山县| 墨竹工卡县| 滦南县| 花莲县| 临颍县| 扬州市|