鍍金池/ 問答/HTML/ vue-cli執(zhí)行npm run build之后無法本地預覽的問題

vue-cli執(zhí)行npm run build之后無法本地預覽的問題

生成dist成功,并且路徑也已經(jīng)改成了assetsPublicPath:‘./’依然無法本地預覽

之前用VUE寫過一個點餐系統(tǒng),用同樣的方式進行了打包可以本地預覽,但是這一次寫的租房系統(tǒng)經(jīng)過打包以后無法本地預覽,只可以服務器模式打開預覽,因此打包spaAPP受阻,出現(xiàn)的總是白頁,請問有沒有人遇到過這種情況。附上打包的配置。

'use strict'
// Template version: 1.1.3
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')

module.exports = {
  build: {
    env: require('./prod.env'),
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './',
    productionSourceMap: true,
    // 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
  },
  dev: {
    env: require('./dev.env'),
    port: process.env.PORT || 8080,
    autoOpenBrowser: true,
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false
  }
}
回答
編輯回答
伴謊

assetsPublicPath: './'改成assetsPublicPath: '/'

2017年11月6日 04:03
編輯回答
近義詞

不掛在服務器上有辦法看么?出現(xiàn)了跟你一樣的問題,只想本地看靜態(tài)頁面效果,打開后是空白頁,也沒有報錯

2017年7月19日 09:53
編輯回答
撥弦

介紹一個比較簡便的方法:
npm install anywhere -g // 全局安裝anywhere模塊
項目npm run build以后 cd dist 命令行輸入anywhere就可以預覽了

2017年4月10日 16:08
編輯回答
歆久

報錯是什么,看看你的router配置

2018年9月21日 09:38