forked from jigneshbhimani/VueJs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path14MakeForm.txt
37 lines (32 loc) · 1.2 KB
/
14MakeForm.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
How to make a Form in Vue Js
- Make 2 input field
- Define property for form
- Bind input field with property
- Submit form
1) Make a component:
- src/components/Login.vue:
<template>
<div>
<input type="text" name="Username" placeholder="enter user name" v-model="loginForm.username" /> <br><br>
<input type="password" name="Password" placeholder="enter user password" v-model="loginForm.password" /> <br><br>
<button v-on:click="loginData">Login</button>
</div>
</template>
<script>
export default {
name: 'Login',
methods:{
loginData(){ // for Login Button
console.log("loginData",this.loginForm.username,this.loginForm.password);
}
},
data(){
return{
loginForm:{ // for Input field
username:null,
password:null
}
}
}
}
- import this component in App.vue