Skip to content
Related Articles

Related Articles

Improve Article

Vue.js Declarative Rendering

  • Last Updated : 11 Feb, 2021
Geek Week

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

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!




My Personal Notes arrow_drop_up
Recommended Articles
Page :