第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在云 firebase 中顯示下拉 Vue js 和類星體

在云 firebase 中顯示下拉 Vue js 和類星體

慕勒3428872 2022-12-18 16:29:32
早上好,我如何獲得一個 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
查看完整描述

1 回答

?
慕絲7291255

TA貢獻1859條經驗 獲得超6個贊

您不是傳遞單個 laboratorios,而是傳遞數組。這應該可以解決問題:


GUI:


<select v-model="lab">

    <option :value = "labItem" v-for = "labItem in labs">{{labItem}}</option>

</select>

數據:


created(){

    // LISTEN FOR LIVE UPDATES

    db.collection("laboratorios").onSnapshot(labs=>{

        // CONCATENATE THE ARRAYS OF EACH DOCUMENT INTO ONE ARRAY AND ASSIGN IT TO VUE DATA.

        this.labs = labs.docs.reduce((x,y)=>{

            return x.concat(y.data().laboratorios);

        }, [])

    })

}


查看完整回答
反對 回復 2022-12-18
  • 1 回答
  • 0 關注
  • 78 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號