![](/img/trans.png)
[英]Editing Json files via node.js from the html input tag(Front end (angularJs+Html))
[英]link front end files HTML, CSS , JS to the backend node.js
我是 web 开发的新手,我最近有一个关于 node.js 和快递的在线课程。 本课程并未真正介绍如何在使用 Node.js 时添加 HTML、CSS 和 JS 文件。
我试过这个:
var express = require('express');
var app = express ();
var port= 3000;
app.use(express.static('public'));
app.listen(port,function(){
console.log('Express app listening on port' +port);
})
app.get('/hello',function(request,response){
response.sendfile('index.html')
})
在这个 server.Js 文件中,我指向了应该在该页面上加载的 HTML 文件。 但是,它加载页面时没有样式,也没有加载其中的图像......
为了使我的前端文件在调用时可用,应该怎么做?
我认为您错过了在index.html
文件中链接CSS
文件
<link rel="stylesheet" href="css/style.css">
假设您的文件夹结构是:
project root
├── server.js
├── package.json
└── public
├── css
└── style.css
├── index.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.