下载

·  阅读 31
<template>
  <div>
    <iframe style="display: none" name="if_down"></iframe>
    <form
      ref="myForm"
      method="get"
      action="url"
      id="if_down"
      target="if_down"
    >
      <input type="hidden" name="id" :value="id" />
    </form>
    <div @click.stop="download">
      <slot>下载</slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "QzDownload",
  props: {
    id: {
      type: String,
      default: "",
    },
  },
  data() {
    return {};
  },
  methods: {
    download() {
      if (!this.id) return this.$ui.showToast("文件id为空");
      try {
        this.$refs.myForm.submit();
      } catch (e) {
        this.$ui.showToast(JSON.stringify(e));
      }
    },
  },
};
</script>

<style scoped></style>
复制代码
分类:
前端
标签:
分类:
前端
标签:
收藏成功!
已添加到「」, 点击更改