Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

第8课 local变量来自哪? #21

Open
Ideal-Li opened this issue Nov 18, 2017 · 1 comment
Open

第8课 local变量来自哪? #21

Ideal-Li opened this issue Nov 18, 2017 · 1 comment

Comments

@Ideal-Li
Copy link
Contributor

Ideal-Li commented Nov 18, 2017

第八课中

express已经帮我们构建好了查找view的位置和解析view的引擎。当我们要返回页面时,只要告诉res.render函数返回的页面的名字即可。

res.render('index', { title: 'Express' });

在官网学习到res.render()可以添加三个参数: 字符串、一个对象(local variable)、一个callback函数。

我的问题是,上面代码中的title,和下面代码中的name,这种local variable是在哪定义的呢?

// pass a local variable to the view
res.render('user', { name: 'Tobi' }, function(err, html) {
  // ...
});
@xugy0926
Copy link
Owner

{title: 'Express'}就是一个对象,title是对象的属性。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants