element [Bug Report] Form 的 validate 方法时,rules type 为 array 有 Bug

siv3szwd  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(175)
export default {
  data() {
    return {
      rules: {
        skus: {
          type: 'array',
          required: true,
          defaultField: {
            type: 'object', required: true,
            fields: {
              name: { required: true, trigger: 'blur', message: 'SKU 名称必须填写' },
              price: { type: 'number', required: true, trigger: 'blur', message: '价格必须填写' },
              stock: { type: 'number', required: true, trigger: 'blur', message: '库存必须填写' },
            }
          }
        }
      }
    }
  },
  methods: {
    submitForm() {
      this.$refs.postForm.validate((valid, obj) => {
        if (valid) {
          console.log('submit!!')
        } else {
          console.log('error submit!!')
          return false
        }
      })
    },
  }
}

当调用 this.$refs.postForm.validate 错误的提示会遍历到所有的数组内
如下图所示:

jc3wubiy

jc3wubiy1#

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

相关问题