这里我包含了javascript,但是我得到的mime类型无效:
<script type="text/javascript" src="{{ asset('/dashboard/js/components.js') }}"></script>
<script type="text/javascript" src="{{ asset('/dashboard/js/custom.js') }}"></script>
<script type="text/javascript" src="{{ asset('/dashboard/vendors/slimscroll/js/jquery.slimscroll.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('/dashboard/vendors/raphael/js/raphael-min.js') }}"></script>
<script type="text/javascript" src="{{ asset('/dashboard/vendors/d3/js/d3.min.js') }}"></script>
<script type="text/javascript" src="{{ asset('/dashboard/vendors/c3/js/c3.min.js') }}"></script>
我收到以下错误:
The script from “http://localhost/Project/public/dashboard/vendors/flotchart/js/jquery.flot.pie.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.[Learn More] home
Loading failed for the <script> with source “http://localhost/Project/public/dashboard/vendors/flotchart/js/jquery.flot.pie.js”. home:2091:1
The script from “http://localhost/Project/public/dashboard/vendors/flot.tooltip/js/jquery.flot.tooltip.min.js” was loaded even though its MIME type (“text/html”) is not a valid JavaScript MIME type.[Learn More]
出什么问题了?请帮忙。
答案 0 :(得分:1)
对我有用的东西:经过半天的研究,我只是尝试编辑JS文件。只需在第一行(带注释的)之后放一个新行(ENTER)并保存。
这是jquery压缩文件,开头带有注释。 在Firefox“检查器/网络”中,.js显示为404和MIME(文本/ html)。 奇怪的是,同一目录中的其他.js文件都可以。 希望有帮助。
答案 1 :(得分:1)
我在Node js应用程序上遇到了同样的问题。您的脚本路径以
开头/dashboard/js/components.js
所以基本上您必须使用
const app = express()
const publicDirectoryPath = path.join(__dirname, '../public/')
app.use(express.static(publicDirectoryPath))
答案 2 :(得分:1)
这是给 nodejs 用户的
最后使用 404 中间件或任何其他中间件
<Directory "c:/wamp64/www/">
#Options FollowSymLinks
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
如果你之前用过这个
app.use(function(req,res,next){
res.send('page does not exist')
})
它会抛出同样的错误