我像这样在脑海中导入 jQuery、boostrap
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"</script>
我正在尝试像这样使用 NodeJS 和 Express,我在 Google 上找到了它
var http = require('http');
var fs = require('fs');
var express = require('express');
var app = express();
http.createServer(function(req, res) {
fs.readFile('main.html', function(err, data) {
res.writeHead(200, {
'Content-Type': 'text/html',
'Content-Length': data.length
});
res.write(data);
res.end();
});
}).listen(8000);
但是当我的页面加载时,这些库没有加载。我也有一些图片
<div class="item active">
<a href="vungtau.html">
<img src="IntroduceImage/VungTau.jpg" alt="Vũng Tàu">
<div class="carousel-caption">
<h3>Vũng Tàu</h3>
<h4>Lần đầu đi Vũng Tàu bằng xe máy</h4>
</div>
</a>
</div>
他们也没有加载。这是地址:D:\Atom Project\IntroduceImage\VungTau.jpg
有谁知道为什么?我在没有 NodeJS 的情况下加载它,就像这个 file:///D:/Atom%20Project/main.html。他们都满载而归。请帮忙,我是 NodeJS 的新手。
您必须提供express.js-staticFile 中给出的文件引用路径
就像是,
const path = require('path');
app.use(express.static('./'));
app.use(express.static(path.join(__dirname, 'public')));
我的图像存储在服务器的根目录中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句