美文网首页
element 使用问题汇总

element 使用问题汇总

作者: sssgoEasy | 来源:发表于2020-03-16 16:18 被阅读0次

1. el-form 配置单个el-form-item ,当该项为数组的处理办法

页面:


image.png

控制台打印结果: ["110000", "110100", "110101"]

rules:

  data(){    
        const validateAddress=(rule, value, callback) => { // 自定义单独配置规则
              if (this.selectedOptions.length===0) {
                  callback(new Error('请确认酒店地址'))
              } else {
                  callback()
              }
          }
        return{
            rules: {
                name: [
                    { required: true, message: "1-10个字符", trigger: "blur" }
                ],
                tel: [
                    {required: true,message: "请填写酒店电话",trigger: "blur"}
                ],
                address:[
                    { required: true, trigger: "blur",validator: validateAddress}
                ],
                business:[
                    {max:20,message:"不超过20字",trigger: "blur"}
                ],
                detail:[
                    {max:225,message:"不超过225字",trigger: "blur"}
                ]
            },
        }
}

参考:

https://blog.csdn.net/qq_41862017/article/details/82223713
https://www.cnblogs.com/beileixinqing/p/10969828.html

总结:

针对特殊规则验证类型或者数组这种格式,可以通过单独配置的方式更方便和快速的解决当前问题

相关文章

网友评论

      本文标题:element 使用问题汇总

      本文链接:https://www.haomeiwen.com/subject/pcxnehtx.html