@csvbox/vuejs3

中文文档
2.0.0发布于 2026/10/26MITTypeScriptESM + CJS近 30 天下载 5386

Vue adapter (Vue Version 3) for csvbox.io

原始使用文档
文档目录7 节
  1. Shell
  2. Usage
  3. Importing a file you already have
  4. Several importers on one page
  5. Closing the importer during an import
  6. Readme
  7. License

@csvbox/vuejs3

Vue adapter for csvbox.io

NPM JavaScript Style Guide

Shell

npm install @csvbox/vuejs3

Usage


<template>
  <div>
    <CSVBoxButton
      :licenseKey="licenseKey"
      :user="user"      
      :onImport="onImport">
      Upload File
    </CSVBoxButton>
  </div>
</template>

<script>
import CSVBoxButton from '@csvbox/vuejs3';

export default {
  name: 'App',
  components: {
    CSVBoxButton,
  },
  data: () => ({
    licenseKey: 'Sheet license key',
    user: {
      user_id: 'default123',
    },
  }),
  methods: {    
    onImport: function (result, data) {    
       if(result) {
          console.log("success");
          console.log(data.row_success + " rows uploaded");
          //custom code
      } else {
          console.log("fail");
          //custom code
      }
    }
  }
}
</script>

Importing a file you already have

openModalWithFile(file) opens the importer on a File your own page is holding — from your own drop target, your own file input, anything — instead of the importer's file picker. The file still goes through the importer's extension, worksheet and size checks; this skips the picker, not the validation.

Call it through a template ref:

<template>
  <div>
    <CSVBoxButton ref="importer" :licenseKey="licenseKey" :user="user" :onImport="onImport">
      Import
    </CSVBoxButton>

    <input type="file" @change="onFileChosen" />
  </div>
</template>

<script>
export default {
  // ...
  methods: {
    onFileChosen(e) {
      this.$refs.importer.openModalWithFile(e.target.files[0]);
    }
  }
}
</script>

The importer can decline a file it is handed, and says why in a console warning ([csvbox] importer declined the supplied file: <reason>):

  • import-in-progress — the importer is open past its upload step, or is still reading an earlier file. An import that is already open stays open.
  • modal-closing — the importer was closing when the file arrived.
  • import-file-url-configured — the sheet is set up to load its own file from a URL.

Pass a File, not a Blob: a Blob has no name to read an extension from, and anything that is not a File is ignored.

When the importer redirects to another host (data-location sheets do this), the file is sent to the host the importer actually ended up on, as long as that host is your importer domain or <region>-<your domain> (for example eu-app.csvbox.io for app.csvbox.io). A file is never sent to any other host.

If the importer does not answer a supplied file within about 8 seconds (for example because it redirected to a host that does not follow that naming, or it is too old to know the message), the importer is put away, the other buttons are enabled again, and the console says [csvbox] the importer did not respond to the supplied file.

Several importers on one page

While an importer is open (or still loading to open), the button of every other CSVBox instance on the page is disabled until it closes, so two importers are not opened by accident. In React, the second argument of the render prop (isLoading) is also true in that state, so a custom trigger can disable itself the same way.

Opening a second importer from code (openModal() or openModalWithFile()) is still possible. The importer opened last is shown on top of the others, and closing it reveals the one underneath.

Closing the importer during an import

If your user submits a file and then closes the importer before the import has finished, the import carries on and your onImport callback is still called with the result when it completes. The importer is reloaded the next time it is opened.

Readme

For usage see the guide here - https://help.csvbox.io/getting-started#2-install-code

License

MIT © csvbox-io

版本与发布记录

@csvbox/vuejs3 共发布 25 个版本,首次发布于 2022/05/09;过去 12 个月发布了 4 个版本。

版本发布日期距今
2.0.0latest2026/10/2615 天前
1.1.122026/09/301 个月前
1.1.112026/09/072 个月前
1.1.102026/08/172 个月前
1.1.92025/07/141.3 年前
1.1.82025/04/211.6 年前

其他发布通道:alpha → 1.1.2-alpha.1。

关于 @csvbox/vuejs3 的常见问题

@csvbox/vuejs3 是什么?

Vue adapter (Vue Version 3) for csvbox.io

如何安装 @csvbox/vuejs3?

在项目目录运行 npm install @csvbox/vuejs3,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:vue(^3.0.5)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@csvbox/vuejs3 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@csvbox/vuejs3 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@csvbox/vuejs3 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=12。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@csvbox/vuejs3 可以商用吗?

@csvbox/vuejs3 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@csvbox/vuejs3 的下载量有多少?

根据 npm 官方下载统计,@csvbox/vuejs3 在 2026/10/11 – 2026/11/09 这 30 天内被下载 5,386 次,日均约 180 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@csvbox/vuejs3 还在维护吗?

最新版本 2.0.0 发布于 2026/10/26(15 天前);至今共发布 25 个版本,其中过去 12 个月发布了 4 个;首次发布于 2022/05/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。