美文网首页
前端直传文件到阿里云 element-ui

前端直传文件到阿里云 element-ui

作者: 西木木亢 | 来源:发表于2019-10-28 09:36 被阅读0次
<el-upload
   :action="oss.host"
   :data="oss"
   list-type="picture-card"
   :file-list="fileList"
   :on-success="handleSuccess"
   :on-preview="handlePictureCardPreview"
   :on-remove="handleRemove"
   >
   <i class="el-icon-plus"></i>
</el-upload>
export default {
  mounted() {
    $http.api("Ipcontent/getPolicy", {}, (s, data, i) => {
      if (s != 1) return this.$alert(i);
      let { dir, host, policy, signature, callback, accessid } = data;
      this.oss.key = dir + this.$dateFormat(new Date() ,'YYYYMMDDHHmmss') + "${filename}";
      this.oss.host = host;
      this.oss.policy = policy;
      this.oss.Signature = signature;
      this.oss.callback = callback;
      this.oss.OSSAccessKeyId = accessid;
    });
  },
  data(){
    return {
      oss: {
        key: "",
        policy: "",
        Signature: "",
        host: "",
        success_action_status: 200,
        callback: ""
      },
    }
  }
}

相关文章

网友评论

      本文标题:前端直传文件到阿里云 element-ui

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