<template>
<div class="container-fluid">
<center><h1>New Employee</h1></center>
<form @submit.prevent="adds" class="form">
<label>Enter Name</label>
<input type="text" class="form-control" v-modle="name">
<label>Enter Employee ID</label>
<input type="text" class="form-control" v-modle="emp_id">
<label>Enter Department</label>
<input type="text" class="form-control" v-modle="dep">
<label>Enter Position</label>
<input type="text" class="form-control" v-modle="position" >
<router-link to="/" class="btn btn-danger btn-lg">Cancel</router-link>
<button type="submit" class="btn btn-outline-success btn-lg">Submit</button>
</form>
</div>
</template>
<script>
import db from '../components/firebaseinit.js'
export default {
name:"newEmployee",
data(){
return{
name: null,
emp_id: null,
dep: null,
position: null
}
},
methods:{
adds(){
db.collection('employee').add({
emp_id: parseInt(this.emp_id),
name: this.name,
dep: this.dep,
position: this.position
}).then(this.router.push("/")).catch(err => console.log(err))
}
}
}
</script>
答案 0 :(得分:0)
then(this.router.push("/")).catch(err => console.log(err))
then(() => this.$router.push("/")).catch(err => console.log(err))