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