From 2545c46ce3f3e58badb6baba058e7e49fe3a0334 Mon Sep 17 00:00:00 2001 From: Dongkyuuuu Date: Tue, 24 Aug 2021 17:34:05 +0900 Subject: [PATCH] feat: add custom component name --- README.md | 9 +++++++-- src/config/install.ts | 6 +++++- src/types/index.ts | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d2b2028..2b793bd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # vue3-recaptcha-v2 -reCAPTCHA for **Vue3** : CompositionAPI, Types +`reCAPTCHA v2` for `Vue3` : CompositionAPI, Types # Installation @@ -30,7 +30,12 @@ import VueRecaptcha from "vue3-recaptcha-v2"; const app = createApp(App); -app.use(VueRecaptcha, { siteKey: "your recaptcha sitekey" }).mount("#app"); +app + .use(VueRecaptcha, { + siteKey: "your recaptcha sitekey", + componentName: "your custom componet name", // default: 'vue-recaptcha' + }) + .mount("#app"); ``` ### Composition API diff --git a/src/config/install.ts b/src/config/install.ts index 01097d3..4e7f27e 100644 --- a/src/config/install.ts +++ b/src/config/install.ts @@ -6,11 +6,15 @@ import { state } from "./state"; const ERROR_MSG_SITEKEY = "options must be included siteKey"; export function install(app: App, options: options) { + const componentName = options.componentName + ? options.componentName + : "vue-recaptcha"; + if (!options.siteKey) throw new Error(ERROR_MSG_SITEKEY); _script(); state.siteKey = options.siteKey; - app.component("vue-recaptcha", VueRecaptcha); + app.component(componentName, VueRecaptcha); } function _script() { diff --git a/src/types/index.ts b/src/types/index.ts index 354debe..4b39181 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -3,6 +3,7 @@ */ export interface options { siteKey: string; + componentName?: string; } /**