Vue.Js Trim String


Vue.Js Trim String– It is very simple to trim string in Vue.Js, we can create filters to trim string in vue.js, Here in this tutorial we are going to create an example which will show how to trim string in Vue.js.


Vue.Js Trim String JavaScript Example

You can trim any string/text in vue.js simply as below-

Vue.Js Trim String Example:

new Vue({

el: '#app',
  
  data: function() {
  	return {
    	text: ' This is string having space at both side. '
    }
  },
  
  filters: {
  
  	trim: function(string) {
    	return string.trim()
        }
  
  }

});
//Usage 
<p>{{ text | trim }}</p>

Try it »

If you run the above example it will produce output without blank space at both end.


Advertisements

Add Comment

📖 Read More