Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptVue.js Declarative Rendering

Vue.js Declarative Rendering

Vue.js is a progressive framework for building user interfaces. The core library is focused on the view layer only and is easy to pick up and integrate with other libraries. Vue is also perfectly capable of powering sophisticated Single-Page Applications in combination with modern tooling and supporting libraries.

Declarative rendering in Vue enables us to render data to the DOM using straightforward template syntax. Double curly braces are used as placeholders to interpolate the required data in the DOM.

The below examples demonstrate declarative rendering in Vue.js:

Example 1:

Filename: index.html

HTML




<html>
<head>
    <script src=
    </script>
</head>
<body>
    <div id='parent'>
        <h3>
          Welcome to the exciting world of {{name}}
          </h3>
        <script src='app.js'>
      </script>
    </div>
</body>
</html>


Filename: app.js

Javascript




const parent = new Vue({
    el : '#parent',
    data : {
      
        // The data that will be
        // interpolated in the DOM
        name : 'Vue.Js'
    }
})


Output:

Declarative Rendering

Example 2:

Filename: index.html

HTML




<html>
<head>
    <script src=
  </script>
</head>
<body>
    <div id='parent'>
        <h3>
          Different Frameworks and
          Libraries in Javascript
          </h3>
        <ul>
            <li>
              <strong>{{priority1}}</strong>
              is Awesome
            </li>
            <li>
              <strong>{{priority2}}</strong
              is quite good
            </li>
            <li>
              <strong>{{priority3}}</strong
              is good too
            </li>
        </ul>
        <script src='app.js'></script>
    </div>
</body>
</html>


Filename: app.js

Javascript




const parent = new Vue({
    el : '#parent',
    data : {
      
        // The data that will be
        // interpolated in the DOM
        priority1: "vue.js",
        priority2: "React.js",
        priority3: "Angular.js"
    }
})


Output:

Declarative rendering

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!

RELATED ARTICLES

Most Popular

Recent Comments