【发布时间】:2021-12-17 13:50:55
【问题描述】:
这是我之前问过的一个相关问题: Get document data from Firestore and show the data into each of the form input field using Nuxt & Vuetify
我希望我提交的数据显示在 v-text-field 输入中。
从图片中可以看出,我可以提交我的表单,我可以相应地获取数据。
名字:siradley_
但我希望它显示在 v-text-field 输入内,而不是在输入字段外。
目前,我还不知道该怎么做。
有什么帮助吗?
<template>
<div>
<v-container>
<v-layout>
<v-flex>
<v-card>
<v-card-text>
<v-form>
<v-layout>
<v-row>
<v-col cols="12" sm="6" md="6" v-for="(test, id) in Test">
<v-text-field
v-model="editedItem.name">{{ test.name }}</v-text-field>
<p>Name: {{ test.name }}</p>
</v-col>
<v-col cols="12" sm="6" md="6">
<v-btn @click="test">Test</v-btn>
</v-col>
</v-row>
</v-layout>
</v-form>
</v-card-text>
</v-card>
</v-flex>
</v-layout>
</v-container>
</div>
</template>
我的脚本
<script>
import firebase from "firebase/app";
import firestore from "@/plugins/firebasetest";
export default {
middleware: "authentication",
layout: 'dashboard',
data: () => ({
Test: [
{
name: '',
}
],
editedItem: {
name: '',
}
}),
created() {
this.readTest();
},
methods: {
readTest() {
this.Test = [];
firestore
.collection('test')
.doc(firebase.auth().currentUser.uid)
.get()
.then((doc) => {
this.Test.push({ ...doc.data(), id: doc.id });
console.log({ ...doc.data(), id: doc.id });
})
},
test() {
var data = {
name: this.editedItem.name,
}
firestore
.collection('test')
.doc(firebase.auth().currentUser.uid)
.set(data)
.then((doc) => {
window.location.reload();
console.log({ ...doc.data, id: doc.id })
})
},
},
}
</script>
【问题讨论】:
标签: firebase google-cloud-firestore nuxt.js vuetify.js