V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cccyuhao
V2EX  ›  前端开发

前端表单验证不通过的问题

  •  
  •   cccyuhao · 2019-09-18 18:32:12 +08:00 · 2305 次点击
    这是一个创建于 1654 天前的主题,其中的信息可能已经有所发展或是发生改变。
    <el-form :model="taskForm" ref='variableForm'>
      <el-tabs v-model="templateActiveName" type="card">
        <el-tab-pane :label="type" :name="type" v-for="type in ['xxx','xx','xxxxx']" :key='type'>
          <el-tabs tab-position="left" v-model="variableActionName">
            <el-tab-pane v-for="(value,key,index) in taskForm[type]" :label="key" :name="key" :key='index'>
              <el-form-item label="变量替换:" :prop="type+key+'data'" :rules="[{required: true, message: '请输入变量替换的值', trigger: 'blur'}]">
                <el-col :span="15">
                  <el-input v-model="taskForm[type][key]['single_data']" placeholder="请输入变量替换的值" @change="check_next_status"></el-input>
                </el-col>
              </el-form-item>
            </el-tab-pane>
          </el-tabs>
        </el-tab-pane>
      </el-tabs>
    </el-form>
    

    使用 VUE+element 的框架。请问为什么这个输入框输入了内容,表单验证依然提示未输入。是因为循环的原因吗?如果改需要改成什么样?谢谢

    2 条回复    2019-10-03 21:24:27 +08:00
    cccyuhao
        1
    cccyuhao  
    OP
       2019-09-19 12:00:39 +08:00
    prop 的位置必须与数据结构中的位置相符。比如要验证“taskFrom.XXX.data”,那么 prop 就要写“XXX.data”。如上 prop 应该使用“:prop='`${type}.${key}.data`'”的方式进行拼接。另外主要就是:prop 了,注意正常验证表单项是 prop,而这里是:prop。这里是`反引号而不是'单引号。
    BaiLinfeng
        2
    BaiLinfeng  
       2019-10-03 21:24:27 +08:00
    完整的代码在哪里啊?怎么双向绑定一会用全写一会用简写尼
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2942 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 39ms · UTC 14:00 · PVG 22:00 · LAX 07:00 · JFK 10:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.