AttachmentButton
AttachmentButton 封装文件选择按钮,用于在输入框中添加附件入口。
导入方式
按需导入
import { AttachmentButton } from '@weimin96/ai-chat-vue'
import '@weimin96/ai-chat-vue/styles'完整导入
import * as AiChatVue from '@weimin96/ai-chat-vue'
import '@weimin96/ai-chat-vue/styles'
app.use(AiChatVue)
// 模板中可直接使用 <AttachmentButton />基础用法
已选择文件数:0
<script setup lang="ts">
import { ref } from 'vue'
import { AttachmentButton } from '@weimin96/ai-chat-vue'
const fileCount = ref(0)
</script>
<template>
<div class="flex items-center gap-3">
<AttachmentButton @attach="(files) => (fileCount = files.length)" />
<span>已选择文件数:{{ fileCount }}</span>
</div>
</template>API
| 事件 | 类型 | 说明 |
|---|---|---|
attach | (files: FileList) => void | 用户选择文件后触发 |
注意事项
组件只负责选择文件,不负责上传和文件预览。