zoukankan      html  css  js  c++  java
  • 记录下自己VUE项目用Hbuider打包后启动白屏问题

     刚用VUE做项目,之前测试时vue创建的自身项目打包都是启动OK没问题。今天打包自己的时,启动一直白屏。折磨了好久,百度了一堆。终于找到了方法。

    首先是在config/index.js里面

    build: {
        // Template for index.html
        index: path.resolve(__dirname, '../dist/index.html'),
    
        // Paths
        assetsRoot: path.resolve(__dirname, '../dist'),
        assetsSubDirectory: 'static',
        assetsPublicPath: './',
    
        /**
         * Source Maps
         */
    
        productionSourceMap: true,
      
        devtool: '#source-map',
    
        productionGzip: false,
        productionGzipExtensions: ['js', 'css'],
        bundleAnalyzerReport: process.env.npm_config_report
      }
    assetsPublicPath我确实也改为了相对路径"./",
    然后在自己配置路由里面。
    const router = new VueRouter({
        mode: "history",//这个有问题,要改为hash
        routes: routers
    });

    网上说mode不能为history。

    百度了下这两个区别,

    history: 依赖 HTML5 History API 和服务器配置。

    hash: 使用 URL hash 值来作路由。支持所有浏览器,包括不支持 HTML5 History Api 的浏览器。

    两个在PC上运行时没什么 区别,但是改为hash后打包后就可以了,没白屏了。

     
  • 相关阅读:
    Deployment.yaml文件
    Python 闭包
    github使用方法(一)
    7.Python 正则表达式学习笔记
    kindle网络爬虫续集
    windows下如何快速搭建web.py开发框架
    Python强大的自省简析
    11--Python 备份文件程序
    10- python 网络爬虫分析
    Python基础学习7---异常处理
  • 原文地址:https://www.cnblogs.com/huzhuhua/p/10620471.html
Copyright © 2011-2022 走看看