【发布时间】:2017-02-06 16:42:40
【问题描述】:
我有一个非常简单的翡翠页面,它没有正确显示从 javascript 路由传入的所有变量。我已经尝试过in this answer 描述的方式,但它不适用于我的情况。我只是想显示 3 个变量:页面标题和两个按钮文本。
目前只有标题显示正确,按钮文本根本不显示。
这是routes/index.js中的代码
/* GET home page. */
router.get('/', function(req, res, next) {
res.render(
'index',
{locals:{
title: 'Real-Time Music Collaborator',
buttonText1: 'Login',
buttonText2: 'Start Creating',
}}
);
});
这是views/layout.jade中的代码
doctype html
html.full-screen
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body.full-screen
block content
这是views/index.jade中的代码
extends layout
block content
div.base-background-colour.no-margin.height-20.padding-100
h1.centre-text.dark-grey-colour.no-margin= title
button
h3.centre-text.dark-grey-colour= buttonText1
button
h3.centre-text.dark-grey-colour= buttonText2
让我感到困惑的是 title 变量如何正常工作,即使我将其更改为使用 = 预先附加但无论我尝试什么它从未显示的两个按钮文本。在呈现的 html 中,按钮文本不存在,因此这不是由类引起的样式问题。
如果有帮助,我正在运行快速版本 4.14.0。
谢谢!
【问题讨论】:
-
可以分享代码而不是截图吗
-
@AshokKumarSahoo 抱歉,我已更正。
标签: javascript node.js express view pug