大佬教程收集整理的这篇文章主要介绍了不能使样式表与node.js的ejs一起工作,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
app.js
var express = require('express'),app = express(),http = require('http'),server = http.createServer(app),fs = require('fs'); var PORT = 8080; app.set('view ENGIne','ejs'); app.get('/',function(req,res){ res.render('board.ejs',{ title: "anything I want",taco: "Hello world",something: "foo bar",layout: false }); }); app.listen(PORT); console.log("Server working");
ejs文件在目录视图/ board.ejs中
<html> <head> <title><%= title %></title> <link rel='stylesheet' href='../styles/style.css' /> </head> <body > <h1> <%= taco %> </h1> <p> <%= something %> </p> </body> </html>
而style.css在相对于app.js的styles / style.css目录中
p { color:red; }
我已经尝试了我可以设想的链接的href的每个路径,包括相对于本地主机相对于board.ejs相对于app.js的位置,甚至只是style.css,但是似乎没有效果.任何建议非常感谢.
以上是大佬教程为你收集整理的不能使样式表与node.js的ejs一起工作全部内容,希望文章能够帮你解决不能使样式表与node.js的ejs一起工作所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。