I use Vuetify to generate input field with:
<v-text-field
label="Search"
v-model="search"
@keyup.enter="search()"
required
></v-text-field>
I want I can key up enter to search from this field:
search () {
alert('test')
}
When I key up on enter key, this method doesn't executed...
Make sure you use your developer console
for debugging so you can see what error messages you are getting:
Windows: ctrl+shift+I
Mac: ⌘+Option+I
The problem you are actually having here is that you have declared search
as a data property and as a method
, so you should see the following message:
[Vue warn]: Method "search" has already been defined as a data property.
To fix this change you method name or your data property name:
new Vue({
el: '#app',
methods: {
search() {
alert('search')
},
},
data: {
searchTerm: ''
}
})
And you should find it works fine.
Here's the JSFiddle: https://jsfiddle.net/er9wsfcy/
I had the same issue and everything was in order, turns out the Browser that i was using was the one with issues.
You can try viewing your console from a different browser eg Chrome.
Maybe this might help someone;