Quasar File Picker 在 ios 中不上传图像

Quasar File Picker doesn't upload image in ios

我想实现图片上传。它适用于网络 (Chrome/Safari),但不适用于移动设备 ios(使用 Capacitor 构建)。它显示图像 selection,但是当我 select 时没有任何反应。

这是我的输入:

    <q-file
      v-model="avatarFile"
      accept=".jpg, .png"
      @input="uploadImage"
    />


async uploadImage() {
 if (this.avatarFile) {
  let extension = "jpg";
  if (this.avatarFile.type === "image/png") {
    extension = "png";
  }
  try {
    this.loading = 1;
    const {
      data: {
        uploadUrl: { uploadUrl },
      },
    } = await this.$apollo.query({
      query: GET_UPLOAD_URL,
      variables: {
        extension,
      },
    });
    await axios.put(uploadUrl, this.avatarFile);
    await setTimeout(() => {
      this.$emit("on-image-upload");
      this.loading = 0;
    }, 3000);
  } catch (e) {
    this.alertError(e);
    this.loading = 0;
  }
 }
}

我做错了什么?提前致谢!

找到解决方案。我的接受规则格式错误。这有效:

accept="image/*"