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/