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

2019-10-28  本文已影响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: ""
      },
    }
  }
}

上一篇 下一篇

猜你喜欢

热点阅读