node.js 提交玉表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10151837/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 15:32:02 来源:igfitidea点击:
Submit Jade form
提问by Feras Odeh
What is the error with the following Jade form template? I can't get it to submit values.
以下 Jade 表单模板有什么错误?我无法让它提交值。
div
form(action='/signup',method='post')
div(data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='email') email
input(id='email',type='text',value='',placeholder='@')
div#passworddiv(data-role='fieldcontain')
fieldset(data-role='controlgroup
label(for='password') password
input(id='password',type='password',value='',placeholder='')
div(id='hiddendiv',data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='hidden_password') password
input(id='hidden_password',type='text',value='',placeholder='')
div(data-role='fieldcontain')
fieldset(data-type='vertical', data-role='controlgroup')
label(for='showpass') show password
input(id='showpass',type='checkbox')
div(data-role='fieldcontain')
input(type='submit',value='Sign Up',data-transition='fade', data-theme='c')
回答by Menztrual
The problem is because you haven't given any of the input fields a name.
问题是因为您没有为任何输入字段指定名称。
app.post('/signup', function(req,res){
console.log(req.body);
})
Returns:
{}
返回:
{}
If you edit the form to the following:
如果您将表单编辑为以下内容:
div
form(action='/signup',method='post')
div(data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='email') email
input(id='email',type='text',value='',placeholder='@',name='email')
div#passworddiv(data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='password') password
input(id='password',type='password',value='',placeholder='',name='password')
div(id='hiddendiv',data-role='fieldcontain')
fieldset(data-role='controlgroup')
label(for='hidden_password') password
input(id='hidden_password',type='text',value='',placeholder='',name='password2')
div(data-role='fieldcontain')
fieldset(data-type='vertical', data-role='controlgroup')
label(for='showpass') show password
input(id='showpass',type='checkbox')
div(data-role='fieldcontain')
input(type='submit',value='Sign Up',data-transition='fade', data-theme='c')
After entering some data,
输入一些数据后,
app.post('/signup', function(req,res){
console.log(req.body);
})
returns:
返回:
{ email: '[email protected]',
password: 'asdf',
password2: 'asdf' }

