On key press of Enter, click a button in vuejs
You can also call method for fb_send directly on input field:
@keyup.enter="enterClicked()"
<Input v-model="value1" size="large" placeholder="large size" @keyup.enter.native="search"></Input>
14 June, 2020
Enter and KeyPress will work both.
Grab the Input fields in a form like this:
<form v-on:keyup.enter="login">
<input type="email" v-model="email">
<input type="password" v-model="password">
<button type="button" @click="login">Login</button>
</form>
Javascript Part:
<script>
export default {
data() {
return {
email: null,
password: null
}
},
methods: {
login() {
console.log("Login is working........");
}
}
}
</script>
Here is my answer fiddle: ANSWER-DEMO
I solved this using $refs.
new Vue({
el:'#app',
methods:{
enterClicked(){
alert("Enter clicked")
},
trigger () {
this.$refs.sendReply.click()
}
}
})