We will learn How to replace string in Vue JS?
<!DOCTYPE html>
<html>
<head>
<title>How to replace string in Vue JS? - rathorji.in</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 rathorji.in"
},
methods:{
myFunction: function () {
this.message = this.message.replace("rathorji.in", "HDTuto.com");
}
}
});
</script>
</html>
May this example help you!