[英]Set input's 'value' attribute from data?
I have a string coming in from the server named 'email'. 我有一个来自名为“ email”的服务器的字符串。 In my pug template I'd like to set the initial value of an input field, but it renders literally as '#{email}' instead of the actual email address. 在我的哈巴狗模板中,我想设置一个输入字段的初始值,但是它实际上显示为“#{email}”,而不是实际的电子邮件地址。 If I remove the quotation marks, the pug file throws an error. 如果删除引号,则pug文件将引发错误。
input(type='text' id='eMailAddress' value='#{email}')
On the server-side: 在服务器端:
res.render('personal-details', {email:req.session.email})
How can I set the value dynamically? 如何动态设置值?
如果您使用的帕格版2+,则可以执行以下操作…
input#eMailAddress(type='text' value=email)
不会为变量解析属性值,您必须直接引用变量:
input(type='text' id='eMailAddress' value=email)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.