<template>
  <a class="downloadAddr" href="./static/收货地址模板.xlsx">
    下载收货地址模板
  </a>
</template>

<script>
export default {
  name: "downloadAddr",
  data() {
    return {
      loading: false,
    };
  },
  mounted() {},
  methods: {
    DownloadTemplate() {
      if (!this.loading) {
        this.loading = true;
        const bloc = dataURLtoBlob(fileUrl);
        const blob = new Blob([bloc], {
          type: "application/vnd.ms-excel",
        });
        const downLoadEle = document.createElement("a");
        // 通过返回的二进制数据来创建一个对象URL.
        const href = URL.createObjectURL(blob);
        downLoadEle.href = href;
        // 信息表为自定义文件名
        downLoadEle.download = "信息表";
        document.body.appendChild(downLoadEle);
        downLoadEle.click();
        document.body.removeChild(downLoadEle);
        // 当加载完成后释放对象URL.
        window.URL.revokeObjectURL(href);
        // window.open(fileUrl, "_blank");
        this.loading = false;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.downloadAddr {
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  background: #ffffff;
  border: 1px solid #6954f0;
  font-size: 12px;
  background-color: #6954f0;
  border-color: #dcdfe6;
  // -webkit-appearance: none;
  text-align: center;
  color: #ffffff;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  outline: none;
  margin: 0;
  -webkit-transition: 0.1s;
  transition: 0.1s;
  // font-weight: 400;
  padding: 7px 15px;
  border-radius: 4px;
}
</style>
