npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

vue3-easy-upload

v1.0.6

Published

简单、高效的 vue 文件上传组件

Readme

Vue3 Easy Upload

一个功能强大、易于使用的 Vue3 文件上传组件,支持分片上传、Web Worker 多线程处理、文件预览等功能。

特性

  • 🚀 Vue3 支持 - 基于 Vue3 Composition API 开发
  • 📦 分片上传 - 支持大文件分片上传,提高上传成功率
  • 🔧 Web Worker - 使用多线程处理文件分片,不阻塞主线程
  • 🎨 TypeScript - 完整的 TypeScript 类型支持
  • 📱 响应式 - 支持多种显示模式(单行/双行)
  • 🎯 灵活配置 - 丰富的配置选项和回调函数
  • 🔍 文件预览 - 支持图片预览和文件下载
  • 🎨 自定义样式 - 支持插槽自定义按钮和标签

安装

npm install vue3-easy-upload
# 或
yarn add vue3-easy-upload
# 或
pnpm add vue3-easy-upload

快速开始

全局注册

import { createApp } from 'vue'
import VueEasyUpload from 'vue3-easy-upload'
import 'vue3-easy-upload/style.css'

const app = createApp(App)
app.use(VueEasyUpload)
app.mount('#app')

按需引入

<template>
  <VueEasyUpload
    v-model="fileList"
    :on-upload="handleUpload"
    :on-delete="handleDelete"
    title="选择文件"
    hint="支持拖拽上传,最大500MB"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { VueEasyUpload } from 'vue3-easy-upload'
import type { FileItem } from 'vue3-easy-upload'

const fileList = ref<FileItem[]>([])

const handleUpload = async (files: FileItem[]) => {
  // 处理文件上传
  console.log('上传文件:', files)
  // 返回上传结果
  return files.map((file) => ({
    id: Math.random().toString(36).substr(2, 9),
    url: 'https://example.com/' + file.name,
  }))
}

const handleDelete = async (file: FileItem) => {
  // 处理文件删除
  console.log('删除文件:', file)
  return true
}
</script>

API

Props

| 参数 | 类型 | 默认值 | 说明 | | -------------- | --------------------------- | ---------------------------------------- | ------------------- | | modelValue | FileItem[] | [] | 文件列表(v-model) | | noBtn | boolean | false | 是否隐藏上传按钮 | | fragment | boolean | false | 是否启用分片上传 | | fragmentSize | number | 2 _ 1024 _ 1024 | 分片大小(字节) | | title | string | '添加附件' | 上传按钮文字 | | doubleRow | boolean | false | 是否双行显示 | | createPerson | string | '' | 上传人 | | dateFormat | string | 'YYYY.MM.DD' | 日期格式 | | readonly | boolean | false | 只读模式 | | alwaysShowBtn | boolean | false | 总是显示操作按钮 | | readyNoDelete | boolean | false | 只能删除未上传文件 | | multiple | boolean | false | 是否支持多选 | | hint | string | boolean | '(不超过500M)' | 提示文字 | | sizeLimit | number | string | boolean | 500 _ 1024 _ 1024 | 单文件大小限制 | | fileList | FileItem[] | [] | 初始文件列表 | | filedList | string[] | ['name', 'size', 'createPerson', 'date'] | 显示字段 | | max | number | string | 1995 | 最大文件数量 | | accept | string | '' | 接受的文件类型 | | onUpload | Function | - | 自动上传回调 | | onManualUpload | Function | - | 手动上传回调 | | onDelete | Function | - | 删除回调 | | onPreview | Function | - | 预览回调 | | onDownload | Function | - | 下载回调 |

Events

| 事件名 | 参数 | 说明 | | ----------------- | ----------------------------- | ---------------- | | update:modelValue | FileItem[] | 文件列表更新 | | exceed | File[] | 超出最大数量限制 | | size-limit | File[] | 超出大小限制 | | after-upload | FileItem[] | 上传完成 | | after-delete | FileItem, number | 删除完成 | | error-trap | { type: number, msg: string } | 错误处理 |

Slots

| 插槽名 | 说明 | | ----------- | ------------ | | title | 上传按钮文字 | | preview | 预览按钮 | | download | 下载按钮 | | delete | 删除按钮 | | sizelabel | 大小标签 | | personlabel | 上传人标签 | | datelabel | 日期标签 |

高级用法

分片上传

<template>
  <VueEasyUpload
    v-model="fileList"
    :fragment="true"
    :fragment-size="1024 * 1024"
    :on-upload="handleChunkUpload"
    title="分片上传"
  />
</template>

<script setup lang="ts">
const handleChunkUpload = async (files: FileItem[]) => {
  // 处理分片上传
  for (const file of files) {
    if (file.splitChunks) {
      // 上传分片
      for (const chunk of file.splitChunks) {
        await uploadChunk(chunk, file.fileHash)
      }
    }
  }
  return files.map((file) => ({ id: file.fileHash }))
}
</script>

自定义样式

<template>
  <VueEasyUpload v-model="fileList">
    <template #title>
      <i class="icon-upload"></i>
      自定义上传按钮
    </template>

    <template #preview="{ file }">
      <i class="icon-eye"></i>
    </template>

    <template #download="{ file }">
      <i class="icon-download"></i>
    </template>
  </VueEasyUpload>
</template>

类型定义

interface FileItem {
  already?: boolean
  createPerson?: string
  dateTime?: Date
  date?: string
  blob?: File | Blob
  name: string
  url?: string
  type: string
  size: string
  fileSize?: number
  totalChunks?: number
  splitChunks?: ChunkItem[]
  fileHash?: string
  [key: string]: any
}

interface ChunkItem {
  start: number
  end: number
  index: number
  hash: string
  blob: Blob
}

许可证

MIT License