0๐
โ
If you want to prevent spaces in the input. You can prevent by using @keydown.space.prevent
.
Working Demo :
new Vue({
el: '#app',
data() {
return {
title: ''
}
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
<span>Name: {{title}}</span>
<input type="text" @keydown.space.prevent v-model="title"/>
</div>
0๐
Trim only filter spaces at start and end.If you want remove all spaces,you can use const removeSpaces = (str)=>str.replace(/\s+/g,'')
Source:stackexchange.com