Espero que todos estéis bien. Mi formulario necesita recopilar las direcciones de correo electrónico de los usuarios para almacenarlas en Firebase cloud firestore. Aunque no funciona en este momento, y no he recibido ningún error. Sería genial si me pueden ayudar con este problema.
tecnologías: vue js 3, quasar, base de fuego
<q-form @submit="submitEmail()"> <q-input rounded standout bottom-slots v-model="email" placeholder="enter your email address"> <template v-slot:append> <q-btn rounded icon="add" label="join us" type="submit"/> </template> </q-input> </q-form> import { defineComponent } from "vue"; import { collection, addDoc } from "firebase/firestore"; import db from "../boot/firebase"; export default defineComponent({ name: "PageIndex", data() { return { email: '', date: '', }; }, methods: { submitEmail() { (async () => { const docRef = await addDoc(collection(db, "waitList"), { email: this.email, date: Date.now(), }); console.log("Document written with ID: ", docRef.id); }); }, }, });Intente evitar el envío de formulario predeterminado como este:
<q-form @submit.prevent="submitEmail()"> Luego, también intente refactorizar el método de submitEmail de correo electrónico de esta manera:
methods: { submitEmail() { addDoc(collection(db, "waitList"), { email: this.email, date: Date.now(), }).then(docRef => console.log("Document written with ID: ", docRef.id); }).catch(e => console.log(e)); }, }