早上好,我如何獲得一個 firebase 數組并將其顯示在 Vue js 的下拉列表中我目前有這個我已經看過你的文章,但事實無法顯示數組的數據,我也不知道如何編輯它們以便可以添加更多但主要是在下拉列表中顯示我從 firebase 調用的數據<template> <div class="q-pa-md"> <div class="q-gutter-md row items-start"> <label>laboratorios</label> <input v-model="laboratorios" type="text" class="form-control" /> <q-btn color="primary" @click="guardarLab()" label="Primary" /> <q-select filled multiple clearable use-input use-chips option-label="laboratorios" v-model="lab" :options="labs" style="width: 250px" /> <!-- <select v-model="lab"> <option v-for="(item, index) in labs" :key="index" v-html="item.laboratorios"></option> </select>--> </div> </div></template><script>import { db } from "boot/firebase"; // no olvidar importar dbexport default { data() { return { laboratorios: "", nombre: null, lab: null, multiple: null, labs: [] /* labs:[ 'glicemia','colesterol','trigliceridos','hemograma','perfil lipidico' ], */ }; }, created() { this.leerDatos(); }, methods: { // listar laboratorios de la bd firebase async leerDatos() { try { const restDB = await db.collection("laboratorios").get(); restDB.forEach(res => { console.log(res.id); const laboratorio = { laboratorios: res.data().laboratorios }; this.labs.push(laboratorio); }); } catch (error) { console.log(error); } }, // guardar laboratorio guardarLab() { var lab1 = { laboratorios: this.laboratorios }; this.labs.push(lab1); } }};</script>最后它向我拋出這個enter image description here 我在 Cloud Firestore 數據庫中的是這個enter image description here
在云 firebase 中顯示下拉 Vue js 和類星體
慕勒3428872
2022-12-18 16:29:32