Created
May 14, 2021 13:54
-
-
Save lpj145/d9a03292fa4bc023626f5ec5c663d945 to your computer and use it in GitHub Desktop.
Strong expansable form.
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', | |
provide: { | |
// Try to imagine what you can do with this approach | |
// So much to think :) | |
register(input) { | |
this.inputs.push(input) | |
} | |
}, | |
data: () => ({ | |
inputs: [] | |
}), | |
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