最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何写“用户名”仪表盘页面上?的NodeJS

运维笔记admin9浏览0评论

如何写“用户名”仪表盘页面上?的NodeJS

如何写“用户名”仪表盘页面上?的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

发布评论

评论列表(0)

  1. 暂无评论