我想在我的 vuetify 项目中添加 google recaptcha 3
像这样的谷歌recaptcha 3:
我从这里得到参考:https ://www.npmjs.com/package/vue-recaptcha-v3
第一:我跑npm install vue-recaptcha-v3
第二:我像这样修改我的 main.js :
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './registerServiceWorker'
import vuetify from './plugins/vuetify'
import { VueReCaptcha } from 'vue-recaptcha-v3'
Vue.config.productionTip = false
Vue.use(VueReCaptcha, {
siteKey: '<site key>',
loaderOptions: {
useRecaptchaNet: true
}
})
new Vue({
router,
store,
vuetify,
render: h => h(App),
methods: {
recaptcha() {
this.$recaptcha('login').then((token) => {
console.log(token) // Will print the token
})
}
},
template: '<button @click="recaptcha">Execute recaptcha</button>'
}).$mount('#app')
我的问题是我很困惑从我的组件中调用它
我的Vue组件是这样的:
<template>
<v-container>
...
<v-row>
<v-col
cols="6"
>
<v-form v-model="valid" ref="form"
>
<v-text-field
label="Full Name"
outlined
v-model="fullname"
></v-text-field>
<v-text-field
label="Email"
outlined
v-model="email"
></v-text-field>
<v-text-field
label="Phone"
outlined
v-model="phone"
></v-text-field>
<v-row justify="center">
<v-btn color="green accent-4" :dark="valid" @click="validate()" :disabled="!valid">Save
<v-icon dark right>mdi-checkbox-marked-circle</v-icon>
</v-btn>
</v-row>
</v-form>
</v-col>
</v-row>
...
</v-container>
</template>
<script>
export default {
data: () => ({
})
}
</script>
如何从我的组件中调用 google recaptcha 3?