What is Vue?
Vue is a JavaScript framework that helps to make building interactive and reactive web frontends easier.
* JavaScript framework: a (third-party) library that provides some functionalities and a 'set of rules' on how to use it to build your JavaScript application.
* reactive: like the look and feel of mobile app. Your app is able to react to user input.
Why we need using Vue?
Traditionally, in web apps, you need to wait for a new page to load if you click a link.
Thanks for JavaScript, it can manipulate the HTML Structure (DOM) of the page.
Therefore, in modern JavaScript driven web application, we will not send a request to load a new web page.
Instead, we only do it once. Afterward, we just change the data using JavaScript.
But, using JavaScript may not be ideal!
Let's take a look of below example which we only use plain JavaScript:
index.html
app.js
You will notice that we need to write lots of code to achieve this tiny feature.
Then Vue, the JavaScript framework, can help.
Look at the rewriting version by Vue of the same feature.
index.html
app.js
As you can see, we only need to configure the Vue app, such as properties, methods, and the predicted end result in html. Then Vue will take over to figure out what needs to be created, added, or changed in the DOM.
That is why using JavaScript framework can save you lots of time for development.
No comments:
Post a Comment