Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在Pug中使用条件语句_Html_Pug_Web Frontend - Fatal编程技术网

Html 如何在Pug中使用条件语句

Html 如何在Pug中使用条件语句,html,pug,web-frontend,Html,Pug,Web Frontend,我有下面的PUG代码,我想使用if语句,以便使用for循环打印提交按钮 html head title test link(type="text/css" rel="stylesheet" href="css/styles.css") meta(name="viewport" content="width=device-width, initial-scale=1") body -inputTypes = ['tex

我有下面的PUG代码,我想使用if语句,以便使用for循环打印提交按钮

html
    head
        title test
        link(type="text/css" rel="stylesheet" href="css/styles.css")
        meta(name="viewport" content="width=device-width, initial-scale=1")
    body
        -inputTypes = ['text','email','password','password']
        -placeholders = ['username','email','password','confirm password']
        -values = ['submit']
        div.cont_login
            center
                img(src="images/user.png")
                form(method="post" action="index.html")
                    for i in [0,1,2,3]
                        input(type=inputTypes[i] placeholder=placeholders[i])
                    input(type="submit" value="submit")

这是PUG中if语句的语法:

  if condition
    code
  else if condition2
    code2
  else
    code3

在您的情况下,您需要检查i是否是最后一次迭代(3),然后打印提交输入(如果是)。

谢谢,这很有用