A
Albert Hsu
Guest
Mã:
<div class="tab-content" id="myTabContent">
<div
class="tab-pane fade show active pt-3"
id="profile"
role="tabpanel"
aria-labelledby="profile-tab"
>
<div class="container">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<input
type="text"
name=""
v-model="profile.name"
placeholder="Full name"
class="form-control"
/>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<input
type="text"
v-model="profile.phone"
placeholder="Phone"
class="form-control"
/>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<input
type="text"
v-model="profile.address"
placeholder="Address"
class="form-control"
/>
</div>
</div>
<div class="col-md-8">
<div class="form-group">
<input
type="text"
v-model="profile.postCode"
placeholder="Postcode"
class="form-control"
/>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<input
type="submit"
@click="updateProfile()"
value="Save Changes"
class="btn btn-primary w-100"
/>
</div>
</div>
</div>
</div>
</div>
i paste some form to here , let you know my thought , did I wrong ?
I can get user.uid and render to a form , i want to let user to type other self information , the uid is connect name in register , and other is empty . can anyone help me ? thanks
Mã:
<script>
import { VueEditor } from "vue3-editor";
import { db } from "../firebase.js";
import { getAuth, signOut } from "firebase/auth";
import { doc, onSnapshot, updateDoc } from "firebase/firestore";
export default {
name: "profiles",
components: {
VueEditor,
},
props: {
msg: String,
},
data() {
return {
profiles:[],
profile: {
name: null,
phone: null,
address: null,
postcode: null,
},
account: {
name: null,
email: null,
photoUrl: null,
emailVerified: null,
password: null,
confirmPassword: null,
uid: null,
},
};
},
mounted(){
const auth = getAuth();
const user = auth.currentUser;
const unsub = onSnapshot(doc(db, "profiles", user.uid), (doc) => {
console.log("Current data: ", doc.data())
this.profile=doc.data()
});
},
methods: {
async updateProfile(profile){
const washingtonRef = doc(db, "profiles",profile);
// Set the "capital" field of the city 'DC'
await updateDoc(washingtonRef,this.profile,{
});
},
uploadImage() {},
},
};
</script>
I can get user.uid and render to a form , i want to let user to type other self information , the uid is connect name in register , and other is empty . can anyone help me ? How should I do ?thanks
Answer for: "how to new update data to firestore?"...