首页 > 解决方案 > Vue 3 文件上传验证无法运行我的项目

问题描述

我的意见

        <input
          id="image-input"
          @input="v$.checkfile.$touch()"
          accept="image/png, image/gif, image/jpeg"
          type="file"
          @change="onFileChange(1, $event)"
        />

我的剧本

 export default {
  setup() {
    return { v$: useVuelidate() };
  },
  data() {
    return {
      checkfile: "",
    };
  },
     validations() {
        return {
          checkfile: {
             checkImageFile(event){
                const file = event.target.files;
                if(file){
                 alert(file)
              }else{
                alert("Not file chosen ")
            }
           }
            
          },
        };
      },

我的 vue 3 项目使用 vuelidate 但我的项目文件上传 vuelidate 不起作用我不明白是什么问题请帮助我谢谢。

标签: vuejs2vuejs3

解决方案


推荐阅读