Skip to content

Commit

Permalink
feat: add custom component name
Browse files Browse the repository at this point in the history
  • Loading branch information
Dongkyuuuu committed Aug 24, 2021
1 parent 93715f8 commit 2545c46
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# vue3-recaptcha-v2

reCAPTCHA for **Vue3** : CompositionAPI, Types
`reCAPTCHA v2` for `Vue3` : CompositionAPI, Types

# Installation

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/config/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ import { state } from "./state";
const ERROR_MSG_SITEKEY = "options must be included siteKey";

export function install(app: App<Element>, 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() {
Expand Down
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
export interface options {
siteKey: string;
componentName?: string;
}

/**
Expand Down

0 comments on commit 2545c46

Please sign in to comment.