首页 > 解决方案 > 在哈巴狗中动态形成队形

问题描述

我正在尝试根据用户输入的数字填充输入字段,但无法做到这一点得到错误

Cannot read property 'querySelector' of undefined"

为什么文档未定义?

我的哈巴狗文件

extends base

block content 
  
  form.createCourseForm
    input.form-control#name(type = 'text ' placeholder = 'course name')
    input.form-control#duration(type = 'text ' placeholder = 'course duration')
    input.form-control#img(type = 'text ' placeholder = 'course image')
    input.form-control#price(type = 'text ' placeholder = 'course price')
    input.form-control#description(type = 'text-area ' placeholder = 'course description')
    label curriculum 
     -const el = document.querySelector('#duration').value;
      let v = el
      while v>0
        input#week(type="text" placeholder = 'week ')
        input#wdescription(type="text-area" placeholder = 'week description')
        label lessons 
          input#lname(type="text" placeholder = 'lesson name')
          input#llink(type="url", name="llink" placeholder = 'lesson link')
        -v=v-1
    
    button.btn.btn-primary create course 
    

标签: formsdynamicpug

解决方案


推荐阅读