【问题标题】:Quasar File Picker doesn't upload image in iosQuasar 文件选择器不会在 ios 中上传图像
【发布时间】:2021-03-15 06:49:54
【问题描述】:

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

这是我的输入:

    <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;
  }
 }
}

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

【问题讨论】:

    标签: ios vue.js capacitor quasar-framework quasar


    【解决方案1】:

    找到了解决办法。我的接受规则格式错误。这有效:

    accept="image/*"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-12
      相关资源
      最近更新 更多