Vue js Replace word in String
Vue js Replace word in String– We can use native javascript replace function to replace the string text in VueJS.
Vue js Replace word in String Example
You can replace word/text in string simply as below –
Example:
<!DOCTYPE html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.13/vue.js"></script> </head> <body> <div id="app"> //Usage <p>{{ text | replaceFilter }}</p> </div> <script> new Vue({ el: '#app', data: function() { return { text: 'Hello World!' } }, filters: { replaceFilter: function(string) { return string.replace("World", "America"); } } }); </script> </body> </html> |
Run the above example to see the output.
Advertisements