美文网首页
文件上传限制

文件上传限制

作者: 曹锦花 | 来源:发表于2019-06-17 15:51 被阅读0次

图片上传

————————————————参数
import { BASICURL } from "@/service/getData";



————————————使用
              <Upload
                :action="basicUrl + 'upload'"
                :on-success="uploadSuccessed"
                :on-error="uploadFailed"
                :on-progress="uploading"
                :show-upload-list="false"
                :headers="uploadHeaders"
              >
                <Button type="ghost" :disabled="editor" icon="ios-cloud-upload-outline"></Button>
              </Upload>

              <Upload
                :action="basicUrl + 'upload'"
                :on-success="iosuploadSuccessed"
                accept=".zip"
                :on-error="uploadFailed"
                :on-progress="uploading"
                :show-upload-list="false"
                :headers="uploadHeaders"
              >//zip格式上传
              <Button style="width:120px; margin:0px 20px">{{$t('IOSUpload')}}</Button>
              </Upload>


          <Upload
            :action="basicUrl + 'upload'"
            :on-success="androiduploadSuccessed"
            accept=".json"
            :on-error="uploadFailed"
            :on-progress="uploading"
            :show-upload-list="false"
            :headers="uploadHeaders"
          >//json格式上传
          <Button style="width:120px; margin-right:20px; margin-left:100px">{{$t('AndroidUpload')}}</Button>
          </Upload>

          <span>{{formValidate.resourceUrlAndroid}}</span>

—————————————————————方法

    /* 文件上传时的钩子函数 */
    uploading(event, file, fileList) {
      this.ifShowPercentCircle = true;
      this.percentage = file.percentage;
    },

    /* 文件上传成功时的钩子函数 */
    uploadSuccessed(response, file, fileList) {
      this.formValidate.imgUrl = response.data;
      this.ifShowPercentCircle = false;
      this.$Message.success("上传成功");
    },

    /* 文件上传失败时的钩子函数 */
    uploadFailed(error, file, fileList) {
      this.ifShowPercentCircle = false;
      this.$Message.error("上传失败");
    },
    /* ios文件上传成功时的钩子函数 */
    iosuploadSuccessed(response, file, fileList) {
      this.formValidate.resourceUrlIos = response.data;
      this.ifShowPercentCircle = false;
      this.$Message.success("上传成功");
    },
    /* android文件上传成功时的钩子函数 */
    androiduploadSuccessed(response, file, fileList) {
      this.formValidate.resourceUrlAndroid = response.data;
      this.ifShowPercentCircle = false;
      this.$Message.success("上传成功");
    },

相关文章

网友评论

      本文标题:文件上传限制

      本文链接:https://www.haomeiwen.com/subject/idnafctx.html