How to replace string in Vue JS?

How to replace string in Vue JS?


tutorials -

In example, i will show you how to replace string in vuejs. we will replace string using jquery replace function. we will use jquery code replace function to replace word form string in vue.js.

Below simple example to replace string "Welcome to ItSolutionStuff.com" into "Welcome to HDTuto.com". It is a very simple and basic, so you can easily understand it.

Example:

<!DOCTYPE html>

<html>

<head>

<title>How to replace string in Vue JS? - ItSolutionStuff.com</title>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

</head>

<body>

<div id="app">

<div id="myId" ref="myId">{{ message }}</div>

<button @click="myFunction()">Click Me</button>

</div>

</body>

<script type="text/javascript">

new Vue({

el: '#app',

data: {

message:"Welcome to ItSolutionStuff.com"

},

methods:{

myFunction: function () {

this.message = this.message.replace("ItSolutionStuff.com", "HDTuto.com");

}

}

});

</script>

</html>

I hope it can help you...

Trending On Tutorial Stuff

Our Sponsors

Top Applications in Tutorial Stuff

Top Experts In Tutorial Stuff