组件
下载触发器 Download Trigger
DownloadTrigger:从普通元素触发内存数据的客户端下载,是保存按钮的无头版本。同时暴露组件底层的 composable,用于自定义触发器。
#基础用法
<script setup lang="ts">
import { Button, DownloadTrigger } from "@bysages/vue";
const readingList = [
"# Reading list — the paper-and-ink shelf",
"",
"- Surface ladder and hairlines",
"- The lighting engine's source model",
"- Container queries over viewport breakpoints",
].join("\n");
</script>
<template>
<!-- Headless on its own: with asChild the download rides our button. -->
<DownloadTrigger as-child file-name="reading-list.txt" mime-type="text/plain" :data="readingList">
<Button>Download the reading list</Button>
</DownloadTrigger>
</template>