Created
May 14, 2021 13:45
-
-
Save lpj145/2dd61e7af291ee173b5108f43e8cf74f to your computer and use it in GitHub Desktop.
Simple form without v-models.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
export default { | |
name: 'FormTest', | |
methods: { | |
saveForm({ target }) { | |
const data = new FormData(target) | |
data.forEach((value, key) => { | |
console.log(`Field: ${key}, value: ${value}`) | |
}) | |
// axios.post('/bla', data) You can use direct on axios | |
} | |
} | |
} | |
</script> | |
<template> | |
<form @submit.prevent="saveForm"> | |
<input type="text" name="name"> | |
<input type="radio" name="gender" value="M"> | |
<input type="radio" name="gender" value="F"> | |
<select name="job" id=""> | |
<option>Develop</option> | |
<option>Teach</option> | |
<option>Nerd</option> | |
</select> | |
<button type="submit">Send</button> | |
</form> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment