@gaviti/vue-turnstile

中文文档
1.1.4发布于 2024/12/31MITTypeScriptESM + CJS近 30 天下载 2048

A Vue 3.3.x component wrapper for Cloudflare's Turnstile

原始使用文档
文档目录10 节
  1. Installation
  2. NPM
  3. Yarn
  4. Installation for Vue 2.7.x
  5. Usage
  6. Customization options
  7. Methods
  8. Events
  9. Slots
  10. License

Vue Turnstile

A Vue 3.3.x component wrapper for Cloudflare's Turnstile

Installation

NPM

npm install @gaviti/vue-turnstile

Yarn

yarn add @gaviti/vue-turnstile

Installation for Vue 2.7.x

For Vue 2.7.x support, you should install a version of this package lower than 1.0.0. Please refer to the "master" branch for the related code.

Usage

<template>
  <div>
    <vue-turnstile @verified="token = $event" />
    <div>Token: {{ token }}</div>
  </div>
</template>

<script>
import VueTurnstile from '@gaviti/vue-turnstile';

export default {
  components: {
    VueTurnstile
  },
  data() {
    return {
      token: null,
    };
  },
};
</script>

Customization options

PropTypeDescriptionRequiredDefault
site-keyStringYour Turnstile sitekey - DocsYesN/A
theme'light' | 'dark' | 'auto'Widget themeNo'auto'
size'normal' | 'compact'Widget sizeNo'normal'
auto-resetBooleanAllow to refresh the token after some time (in milliseconds)Nofalse
reset-timeoutNumberRefresh the token after some time (in milliseconds) * requires auto-reset to be trueNo295000
recaptcha-compatBooleanAdds recaptcha compatibility layerNofalse
explicit-renderBooleanRenders the widget explicitlyNofalse
appearance'always' | 'execute' | 'interaction-only'Appearance controls when the widget is visible - DocsNoalways
LanguageStringLanguage to display - ISO 639-1 two-letter language code - Supported languagesNoauto

Methods

MethodDescription
render()Render the widget
reset()Reset the widget
remove()Remove the widget
getToken()Generates a new token

Events

NameParamsDescription
@verifiedReturns the token
@renderingEmitted on mounted (returns nothing)
@renderedEmitted at the end of render (returns nothing)
@errorcodeCallback invoked when there is an error (e.g. network error or the challenge failed).

Slots

NameDescription
defaultDefault slot

License

MIT License

Copyright (c) 2024 Gaviti

版本与发布记录

@gaviti/vue-turnstile 共发布 50 个版本,首次发布于 2023/08/23;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.1.4latest2024/12/311.9 年前
1.1.32024/12/311.9 年前
0.6.52024/12/311.9 年前
0.6.42024/12/311.9 年前
0.6.32024/07/242 年前
1.1.22024/07/242 年前

关于 @gaviti/vue-turnstile 的常见问题

@gaviti/vue-turnstile 是什么?

A Vue 3.3.x component wrapper for Cloudflare's Turnstile

如何安装 @gaviti/vue-turnstile?

在项目目录运行 npm install @gaviti/vue-turnstile,或使用 pnpm add / yarn add / bun add。

@gaviti/vue-turnstile 支持 TypeScript 吗?

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

@gaviti/vue-turnstile 支持 ESM 还是 CommonJS?

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

@gaviti/vue-turnstile 需要什么版本的 Node.js?

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

@gaviti/vue-turnstile 可以商用吗?

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

@gaviti/vue-turnstile 的下载量有多少?

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

@gaviti/vue-turnstile 还在维护吗?

最新版本 1.1.4 发布于 2024/12/31(1.9 年前);至今共发布 50 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/08/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。