且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

资源由于使用pug和node的MIME类型不匹配而被阻止

更新时间:2022-11-21 14:31:22

这是因为您在属性中使用了相对URL.

This is because you are using relative url's in your attributes.

替换此:

link(href='img/favicon.png' rel='icon')

与此:

link(href='/img/favicon.png' rel='icon')

为进一步解释这一点,当您查看/employee 时,位于 img/123.jpg 的相对链接被正确解析为/img/123.jpg .但是,一旦您转到URL /employee/joeblow ,则相对链接就会查找/employee/img/123.jpg .通过在浏览器中打开开发人员工具",然后查看网络"标签中的请求,您可以确认这一点.

To explain this further, when you are viewing /employee then the relative link at img/123.jpg is correctly resolved as /img/123.jpg. However, as soon as you go to the url /employee/joeblow then the relative link is looking for /employee/img/123.jpg. You'll be able to confirm this by opening Developer Tools in your browser then looking at the requests made in the Network tab.

在所有 img 元素的前面添加斜杠将确保它们在正确的文件夹(根目录(/))中查找图像.

Adding the slash at the front of all img elements will ensure that they look for the images in the correct folder, the one off the root (/).

bootstrap mime-type错误必须来自可以正确加载但由于上述问题而没有找到依赖项的库之一.

The bootstrap mime-type error must be coming from one of the libraries that is loading correctly but not finding a dependency due to the issue described above.