Vue.js Substring
Vue.js Substring Function– It is very simple to get the substring of a string in Vue.js. We can create filters to get the substring from a string.
Vue.js Substring Function JavaScript Example
We can use native javascript substring method to get a substring of a string. Let us create an example to get the substring from string –
Vue.js Substring Example:
<html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.3.0/vue.js"></script> </head> <body> <div id="app"> <p>{{ text | subStr}}</p> </div> <script> new Vue({ el: '#app', data: function() { return { text: ' This is sample string to show trim method. ' } }, filters: { subStr: function(string) { return string.substring(0,15) + '...'; } } }); </script> </body> </html> |
If you run the above example it will produce output something like this-
Advertisements