【问题标题】:How to validate multiple file form field using vee-validate?如何使用 vee-validate 验证多个文件表单字段?
【发布时间】:2018-04-16 10:56:17
【问题描述】:

我有一个多文件选择表单字段,我正在使用 v-validate 来验证它。如何验证这种字段?

<input type="file" name="images[]" ref="file" class="txt" v-validate="'required|image|mimes:jpg,png,jpeg'">
<span v-show="errors.has('images')">{{ errors.first('images') }}</span>
<input type="file" name="images[]" ref="file" class="txt" v-validate="'required|image|mimes:jpg,png,jpeg'">
<span v-show="errors.has('images')">{{ errors.first('images') }}</span>

我没有使用多个。相反,我在两个不同行的两个输入类型中使用images[]

【问题讨论】:

    标签: vue.js single-page-application vee-validate


    【解决方案1】:

    名称应该是“images”而不是“images[]”。我们只需要在应用程序中将图像初始化为空数组

      data: function() {
        return {
          images: []
        }
      },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-06-20
      • 2019-08-14
      • 1970-01-01
      • 2021-09-14
      • 2018-10-09
      • 2019-12-30
      • 1970-01-01
      相关资源
      最近更新 更多