3π
β
Found an answer:
Adding a v-model to it and then setting that have a empty string seems to do the trick.
<input type="text" placeholder="Search for tags..." v-on:keyup.enter="searchTag" v-model="searchText">
export default {
data() {
return {
tags: [
],
searchText: ""
}
},
methods: {
searchTag: function(event) {
var newtag = event.target.value;
this.tags.push({name: newtag});
this.searchText = "";
}
}
}
Note that the searchText is set to ββ at the end of the search function.
π€user3479267
2π
Just bind the input value to a variable and then clear it on the event like this :
data{
input : ''
},
methods: {
searchTag: function() {
this.input = '';
}
}
<input type="text" placeholder="Search for tags..." v-on:keyup.enter="searchTag" v-model="input">
Source:stackexchange.com