Vue.js


Vue.js is an open-source model–view–viewmodel JavaScript framework for building user interfaces and single-page applications. It was created by Evan You, and is maintained by him and the rest of the active core team members coming from various companies such as Netlify and Netguru.

Overview

Vue.js features an incrementally adaptable architecture that focuses on declarative rendering and component composition. The core library is focused on the view layer only. Advanced features required for complex applications such as routing, state management and build tooling are offered via officially maintained supporting libraries and packages, with Nuxt.js as one of the most popular solutions
Vue.js lets you extend HTML with HTML attributes called directives. The directives offer functionality to HTML applications, and come as either built-in or user defined directives.

History

Vue was created by Evan You after working for Google using AngularJS in a number of projects. He later summed up his thought process: "I figured, what if I could just extract the part that I really liked about Angular and build something really lightweight." The first source code commit to the project was dated July 2013, and Vue was first released the following February, in 2014.

Versions

Features

Components

Vue components extend basic HTML elements to encapsulate reusable code. At a high level, components are custom elements to which the Vue’s compiler attaches behavior. In Vue, a component is essentially a Vue instance with pre-defined options.
The code snippet below contains an example of a Vue component. The component presents a button and prints the number of times the button is clicked:

Templates

Vue uses an HTML-based template syntax that allows binding the rendered DOM to the underlying Vue instance's data. All Vue templates are valid HTML that can be parsed by specification-compliant browsers and HTML parsers. Vue compiles the templates into virtual DOM render functions. A virtual Document Object Model allows Vue to render components in its memory before updating the browser. Combined with the reactivity system, Vue is able to calculate the minimal number of components to re-render and apply the minimal amount of DOM manipulations when the app state changes.
Vue users can use template syntax or choose to directly write render functions using JSX. Render functions allow application to be built from software components.

Reactivity

Vue features a reactivity system that uses plain JavaScript objects and optimized re-rendering. Each component keeps track of its reactive dependencies during its render, so the system knows precisely when to re-render, and which components to re-render.

Transitions

Vue provides a variety of ways to apply transition effects when items are inserted, updated, or removed from the DOM. This includes tools to:
When an element wrapped in a transition component is inserted or removed, this is what happens:
  1. Vue will automatically sniff whether the target element has CSS transitions or animations applied. If it does, CSS transition classes will be added/removed at appropriate timings.
  2. If the transition component provided JavaScript hooks, these hooks will be called at appropriate timings.
  3. If no CSS transitions/animations are detected and no JavaScript hooks are provided, the DOM operations for insertion and/or removal will be executed immediately on next frame.

    Routing

A traditional disadvantage of single-page applications is the inability to share links to the exact "sub" page within a specific web page. Because SPAs serve their users only one URL-based response from the server, bookmarking certain screens or sharing links to specific sections is normally difficult if not impossible. To solve this problem, many client-side routers delimit their dynamic URLs with a "hashbang", e.g. page.com/#!/. However, with HTML5 most modern browsers support routing without hashbangs.
Vue provides an interface to change what is displayed on the page based on the current URL path -- regardless of how it was changed. Additionally, using a front-end router allows for the intentional transition of the browser path when certain browser events occur on buttons or links. Vue itself doesn’t come with front-end hashed routing. But the open source "vue-router" package provides an API to update the application's URL, supports the back button, and email password resets or email verification links with authentication URL parameters. It supports mapping nested routes to nested components and offers fine-grained transition control. With Vue, developers are already composing applications with small building blocks building larger components. With vue-router added to the mix, components must merely be mapped to the routes they belong to, and parent/root routes must indicate where children should render.
The code above:
  1. Sets a front-end route at websitename.com/user/.
  2. Which will render in the User component defined in
  3. Allows the User component to pass in the particular id of the user which was typed into the URL using the $route object's params key: $route.params.id.
  4. This template will be rendered into inside the DOM's div#app.
  5. The finally generated HTML for someone typing in: websitename.com/user/1 will be:

    Ecosystem

The core library comes with tools and libraries both developed by the core team and contributors.

Official Tooling