Javascript 如何将引导css样式表合并到express/node js中?
所以目前,我采用的方法是使用这些代码来检索我的html文件Javascript 如何将引导css样式表合并到express/node js中?,javascript,css,node.js,express,Javascript,Css,Node.js,Express,所以目前,我采用的方法是使用这些代码来检索我的html文件 app.get("/", function (request, response) { response.sendFile(__dirname + "/public_html/index.html"); }) html文件是一个带有method=“post”的表单和一个提交表单的按钮。我已经在这里导入了相关的css代码 <link rel="stylesheet"
app.get("/", function (request, response) {
response.sendFile(__dirname + "/public_html/index.html");
})
html文件是一个带有method=“post”的表单和一个提交表单的按钮。我已经在这里导入了相关的css代码
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
还有一部分我不确定我是否采取了错误的方法
我使用一些response.write()方法来显示表单结果
response.write('<h1>SURVEY REPORT</h1>');
response.write('<dl><dd><strong>Firstname entered: </strong>' + firstname + '</dd>');
response.write('<dd><strong>Surname entered: </strong>' + surname + '</dd>');
etc...
response.write(“调查报告”);
响应。写入(“输入的名字:”+Firstname+”);
回答。写(“输入姓氏:”+姓氏+”);
等
虽然这样做是可行的,但它似乎根本没有实现css样式表。如何使css样式表与输出一起工作
我也尝试过通过sqlite3在内存中创建sql数据库并将值存储在那里,但现在我一直在思考如何使用该表输出为html格式。这不是更好的方法 你可以选择你自己或者ejs 在app.js上添加此行
app.set('view engine', 'hbs');
然后,您可以通过以下方式响应请求:-
res.render('/filepath/index.hbs', {write variables for the file as json})
res.render('/filepath/index.hbs', {write variables for the file as json})