@csvbox/vuejs

中文文档
2.0.0发布于 2026/10/26MITTypeScriptCommonJS近 30 天下载 5208

Vue adapter for csvbox.io

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

@csvbox/vuejs

Vue adapter for csvbox.io

NPM JavaScript Style Guide

Shell

npm install @csvbox/vuejs

Usage


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

<script>
import { CSVBoxButton } from '@csvbox/vuejs';

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.

Readme

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

License

MIT © csvbox-io

版本与发布记录

@csvbox/vuejs 共发布 35 个版本,首次发布于 2021/08/31;过去 12 个月发布了 3 个版本。

版本发布日期距今
2.0.0latest2026/10/2615 天前
1.1.132026/09/301 个月前
1.1.122026/08/172 个月前
1.1.112025/07/141.3 年前
1.1.102025/04/211.6 年前
1.1.92024/07/252 年前

其他发布通道:alpha → 1.1.5-alpha.2。

关于 @csvbox/vuejs 的常见问题

@csvbox/vuejs 是什么?

Vue adapter for csvbox.io

如何安装 @csvbox/vuejs?

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

@csvbox/vuejs 支持 TypeScript 吗?

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

@csvbox/vuejs 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@csvbox/vuejs 可以商用吗?

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

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

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

@csvbox/vuejs 还在维护吗?

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