前端本地文件上传生成临时url(文件不上传云端)

文件本地上传生成临时url

          <input type="file" name="file" accept="image/png, image/jpeg, image/jpg" @change="change" style="margin-top: 30px"/>

可使用URL.createObjectURL将上传的文件生成临时url

    change() {
      //生成的临时url
      const url = URL.createObjectURL(document.querySelector('input[type=file]').files[0]);
      this.recognize(url);
    },

猜你喜欢

转载自blog.csdn.net/god_sword_/article/details/131878486