我有一个应该输出小内容的简单应用程序。我使用 NodeJs,Express和Pug 。
**\*.trx
我的Pug文件/ HTML
const pug = require('pug');
const express = require('express');
const app = express();
const indexFile = 'index'; // the file to load
app.set('view engine', 'pug'); // use pug
app.get('/', function (req, res) {
res.render(indexFile, {content: 7}); // load the file and set the variable to 7
});
app.listen(8888, function () {
console.log('Server running on port 8888');
});
启动服务器时收到此错误消息
doctype html
link(rel='stylesheet', href='../CSS/requirements.css')
script(src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js')
body
p = content
有人可以帮助我吗?
答案 0 :(得分:4)
我认为您在html
之后忘了doctype html
。
doctype html
html
link(rel='stylesheet', href='../CSS/requirements.css')
script(src='https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js')
body
p=content
doctype html
和html
应处于相同的意图级别。顺便说一句,将p = content
更改为p=content
以打印传递值