【发布时间】:2015-06-28 09:09:30
【问题描述】:
我将expressjs 作为本地服务器运行。我收到这样的错误..这里有什么问题?
Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://localhost:3000/js/lib/bootstrap/dist/css/bootstrap.min.css".
localhost/:11 Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/js/lib/angular/angular.min.js".
localhost/:10 Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/js/lib/jquery/dist/jquery.min.js".
localhost/:12 Resource interpreted as Script but transferred with MIME type text/html: "http://localhost:3000/js/scripts/app.js".
这是我的html:
<!DOCTYPE html>
<html ng-app="myNewApp">
<head>
<meta charset="utf-8"> //i already declared the content type here.
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>My New App!</title>
<link rel="stylesheet" href="/js/lib/bootstrap/dist/css/bootstrap.min.css">
</head>
<body>
<script src="/js/lib/jquery/dist/jquery.min.js"></script>
<script src="/js/lib/angular/angular.min.js"></script>
<script src="/js/scripts/app.js"></script>
</body>
</html>
我的server.js:
var express = require("express"),
app = express();
app
.use(express.static( __dirname + 'public'));
app
.get('*', function (req, res) {
res.sendfile('public/main.html');
})
app.listen(3000);
【问题讨论】:
-
为什么是
app.get('*',...而不是app.get('/',...? -
我猜两者都是一样的。
*小心点... -
我不这么认为。换个试试看
标签: html express content-type