Refused to apply ** from ‘url‘ because its MIME type (‘text/html‘) is not a supported ** MIME type,

1. 项目环境版本

  • @vue/cli-service: ‘~5.0.0’

2. 问题描述

执行build脚本打包,编译后,访问indexm.html页面,报错。

在这里插入图片描述

Refused to apply style from 'http://localhost:63342/css/app.fe9f3cca.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Failed to load resource: the server responded with a status of 404 (Not Found)

Refused to execute script from 'http://localhost:63342/js/chunk-vendors.f1ad1f4f.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Failed to load resource: the server responded with a status of 404 (Not Found)

Refused to execute script from 'http://localhost:63342/js/app.1657eaa6.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

Refused to apply style from 'http://localhost:63342/css/app.fe9f3cca.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

3. 解决思路

  • 右键上面报错中的任意一个地址,点击Open in new tab,发现访问结果是404
    在这里插入图片描述
    从而怀疑,是静态文件的publicPath配置问题。
  • 打开vue.config.js文件。
    在这里插入图片描述

在配置中添加

  publicPath: './'

把静态资源的请求路径改为相对路径。

  • 再次打包,问题解决。
    在这里插入图片描述
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值