Sunday, December 29, 2024
Google search engine
HomeLanguagesJavascriptVue.js | v-text directive

Vue.js | v-text directive

The v-text directive is a Vue.js directive used to update a element’s textContent with our data. It is just a nice alternative to Mustache syntax. First, we will create a div element with id as app and let’s apply the v-text directive to this element with data as a message. Now we will create this message by initializing a Vue instance the data attribute containing our message.

Syntax: 

v-text="data"

Parameters: This directive accepts a single parameter which is the data.
Example: This example uses VueJS to update the text of a element with v-text. 

HTML




<!DOCTYPE html>
<html>
  
<head>
    <title>
        VueJS | v-text directive
    </title>
  
    <!-- Load Vuejs -->
    <script src=
    </script>
    </script>
</head>
  
<body>
    <div style="text-align: center;width: 600px;">
        <h1 style="color: green;">
            neveropen
        </h1>
        <b>
            VueJS | v-text directive
        </b>
    </div>
  
    <div id="canvas" style="border:1px solid #000000;
                            width: 600px;height: 200px;">
        <div v-text="message" id="app">
        </div>
    </div>
  
    <script>
        var app = new Vue({
            el: '#app',
            data: {
                message: 'Hello this is neveropen.'
            }
        })
    </script>
</body>
  
</html>
                    


Output: 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments