如何写“用户名”仪表盘页面上?的NodeJS
我做了一个登录系统,当用户登陆我想写他的仪表盘上的用户名。
我尝试:
<h2 class="page-header">Dashboard</h2>
<p>Welcome to your dashboard {{username}}</p>
但它不工作
router.post('/register', (req, res) => {
var name = req.body.name;
var username = req.body.username;
var email = req.body.email;
var password = req.body.password;
var password2 = req.body.password2;
// VALIDATION
req.checkBody('name','Name is required').notEmpty();
req.checkBody('username','Username is required').notEmpty();
req.checkBody('email','Email is required').notEmpty();
req.checkBody('email','Email is not valid').isEmail();
req.checkBody('password','Password is required').notEmpty();
req.checkBody('password2','Passwords do not match').equals(req.body.password);
)}
我能做什么 ?
回答如下:你所要做的是与用户名渲染视图作为本地variable.This可以用快递res.render()函数来完成。例如:res.render('view',{username: ''});
.You可以更好地理解看看这个文件 - https://expressjs/en/api.html#res.render
如何写“用户名”仪表盘页面上?的NodeJS
我做了一个登录系统,当用户登陆我想写他的仪表盘上的用户名。
我尝试:
<h2 class="page-header">Dashboard</h2>
<p>Welcome to your dashboard {{username}}</p>
但它不工作
router.post('/register', (req, res) => {
var name = req.body.name;
var username = req.body.username;
var email = req.body.email;
var password = req.body.password;
var password2 = req.body.password2;
// VALIDATION
req.checkBody('name','Name is required').notEmpty();
req.checkBody('username','Username is required').notEmpty();
req.checkBody('email','Email is required').notEmpty();
req.checkBody('email','Email is not valid').isEmail();
req.checkBody('password','Password is required').notEmpty();
req.checkBody('password2','Passwords do not match').equals(req.body.password);
)}
我能做什么 ?
回答如下:你所要做的是与用户名渲染视图作为本地variable.This可以用快递res.render()函数来完成。例如:res.render('view',{username: ''});
.You可以更好地理解看看这个文件 - https://expressjs/en/api.html#res.render