出現:Refused to apply style from 'XXX.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
我的錯誤,由於html打開正常,所以肯定是 node.js 代碼問題,
這裏是因爲node環境下使用express框架的靜態資源訪問,需要設置靜態文件目錄;
代碼如下:
const express = require('express');
const app = express();
var path = require('path');
//加載靜態資源,CSS資源在這個static文件夾下即可
app.use(express.static(path.join(__dirname, './static')));
// 處理根目錄的get請求
app.get('/login',function(req,res){
res.sendfile('./static/login.html') ;
console.log('ok');
});