vue打包后,网页打开是空白页的解决办法

news/2024/7/23 22:01:55 标签: vue.js
在config文件夹下的index.js中,找到
assetsPublicPath: '/'
然后改成
assetsPublicPath: './'
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,
    // 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
  }

http://www.niftyadmin.cn/n/861590.html

相关文章

vue中时间戳准换时间过滤器和小数点装换百分比的过滤器

vue中时间戳准换时间过滤器 组件化 新建一个js文件添加以下代码 export function formatDate(date, num) {if (/(y)/.test(num)) {num num.replace(RegExp.$1, (date.getFullYear() ).substr(4 - RegExp.$1.length));}let o {M: date.getMonth() 1,d: date.getDate(),h:…

vue的项目启动,我们需要连接其他电脑来跑项目的时候,就需要把ip地址换成需要连接电脑的ip地址。在config文件夹下的index.js的文件里面添加修改

平时的开发中,我们需要连接其他电脑来跑项目的时候,就需要把ip地址换成需要连接电脑的ip地址。在config文件夹下的index.js的文件里面添加修改 dev: {// PathsassetsSubDirectory: static,assetsPublicPath: /,proxyTable: {/api: {target: http://192.…

在开发中,我们需要对后端返回来的数据进行转型,后端返回的字符串类型,布尔类型,进行使用

后端返回 num:12.598 num2:11.222 这种字符串的数字,在前端需要根据这个数字来做一些判断的时候,直接 if(num > num2){console.log(方法) } 这样子操作,很明显是不可以的,所以我们需要进行转换数据类型parseFloat浮点 if(parse…

vue项目报错Trailing spaces not allowed.

vue项目报错Trailing spaces not allowed. 是因为vue-cli的eslint的语法规范导致的 你可以把eslint给关闭了 在使用vue-cli脚手架来生成vue项目文件的时候,会发现有个自带的代码规范eslint,非常麻烦,其实你只要找到.eslintrc.js里面&#…

数组类型方法

数组类型方法 1.concat,创建一个新数组,将array与任何数组 或 值连接在一起。 let arr [1,2,3,4] let arr2 [9] let arr3 arr.concat(arr2) console.log(arr3); //[ 1, 2, 3, 4, 9 ]2.pop,删除数组的最后一个元素,返回值为最…

vscode快速打出vue项目模块

在vscode的文件 》首选项 》 用户片段 然后再搜索框输入vue&#xff0c;回车&#xff0c;打开vue.json文件&#xff0c;添加下面这个代码 {"Print to console": {"prefix": "vue","body": ["<template>"," &l…

vant实现列表分页加载和下拉刷新

<template><div class"hello"><van-pull-refresh v-model"isLoading" refresh"onRefresh"><div class"container"><div v-ifnoData>暂无数据</div><template v-else><van-listv-model&q…

微信小程序的wx-request请求

var that thisvar url urlvar random Math.random()if(!this.data.phone || !this.data.password){wx.showToast({title: 不能为空,icon: none,duration: 1000,mask:true})wx.hideToast();return}wx.request({url: url,data:{phone:this.data.phone,pwd:this.data.password,…