ItSolutionStuff.com

How to Replace String in Vue JS?

By Hardik Savani • June 30, 2023
Vue.JS

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...

Tags: Vue.JS
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

How to Use Ternary Operator in Vue JS?

Read Now →

How to Define Global Variables in Vue JS?

Read Now →

Vue JS Ajax Form Submit Example Code

Read Now →

Vue JS Toggle Switch Button Example

Read Now →

Vue Toastr Notifications Example Code

Read Now →

How to Create and Use Component in Vue JS Cli?

Read Now →

How to Open a Link in a New Tab in Vue JS?

Read Now →

How to Use setTimeout Function in Vue JS?

Read Now →

How to Check Object or Array Empty or Not in Vue JS?

Read Now →

How to Get Element by ID in Vue JS?

Read Now →

Laravel Vue Router Example From Scratch

Read Now →

Laravel Vue Flash Message Example From Scratch

Read Now →

Laravel Vue JS File Upload Using Vue-dropzone Example

Read Now →