Vue.Js String Substr
This method is used to extract the characters from a string beginning form specified character to the number of characters. You can use this function same as native JavaScript. You can also use our online editor to edit and run the code online.
Vue.Js String Substr Method Example
You can use substr function in vue.js simply as below-
Example:
<div id="app"> <div id="myId" ref="myId">{{ substr }}</div> <button @click="myFunction()">Click Me</button> </div> <script> new Vue({ el: '#app', data: { str:"Welcome to Canada!", substr: "" }, methods:{ myFunction: function () { this.substr = this.str.substr(1, 4); } } }); </script> |
Output of above example-
Advertisements