Vue.js (commonly referred to as Vue; pronounced "view"
) is an
open-source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
model–view–viewmodel
Model–view–viewmodel (MVVM) is an architectural pattern in computer software that facilitates the separation of the development of the graphical user interface (GUI; the ''view'')—be it via a markup language or GUI code—from the developme ...
front end JavaScript framework
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build an ...
for building
user interface
In the industrial design field of human–computer interaction, a user interface (UI) is the space where interactions between humans and machines occur. The goal of this interaction is to allow effective operation and control of the machine f ...
s and
single-page application
A single-page application (SPA) is a web application or website that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of a web browser loading entire new pages. ...
s. It was created by Evan You, and is maintained by him and the rest of the active core team members.
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
Routing is the process of selecting a path for traffic in a network or between or across multiple networks. Broadly, routing is performed in many types of networks, including circuit-switched networks, such as the public switched telephone netw ...
,
state management and
build tooling are offered via officially maintained supporting libraries and packages.
Vue.js allows for extending
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
with HTML attributes called directives. The directives offer functionality to HTML
applications
Application may refer to:
Mathematics and computing
* Application software, computer software designed to help the user to perform specific tasks
** Application layer, an abstraction layer that specifies protocols and interface methods used in a c ...
, and come as either
built-in or user defined directives.
History
Vue was created by Evan You after working for
Google
Google LLC () is an American Multinational corporation, multinational technology company focusing on Search Engine, search engine technology, online advertising, cloud computing, software, computer software, quantum computing, e-commerce, ar ...
using
AngularJS
AngularJS is a discontinued free and open-source JavaScript-based web framework for developing single-page applications. It was maintained mainly by Google and a community of individuals and corporations. It aimed to simplify both the developm ...
in several 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.
Version names are often derived from
manga
Manga ( Japanese: 漫画 ) are comics or graphic novels originating from Japan. Most manga conform to a style developed in Japan in the late 19th century, and the form has a long prehistory in earlier Japanese art. The term ''manga'' is use ...
and
anime
is hand-drawn and computer-generated animation originating from Japan. Outside of Japan and in English, ''anime'' refers specifically to animation produced in Japan. However, in Japan and in Japanese, (a term derived from a shortening of ...
, most of which are within the
science fiction
Science fiction (sometimes shortened to Sci-Fi or SF) is a genre of speculative fiction which typically deals with imagination, imaginative and futuristic concepts such as advanced science and technology, space exploration, time travel, Paral ...
genre.
Versions
When a new major is released ie v3.y.z, the last minor ie 2.x.y will become a LTS release for 18 months (bug fixes and security patches) and for the following 18 months will be in maintenance mode (security patches only).
Features
Components
Vue components extend basic
HTML element
An HTML element is a type of HTML (HyperText Markup Language) document component, one of several types of HTML nodes (there are also text nodes, comment nodes and others). The first used version of HTML was written by Tim Berners-Lee in 1993 ...
s 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
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
-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
Parsing, syntax analysis, or syntactic analysis is the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lat ...
. Vue compiles the templates into
virtual DOM render functions. A virtual Document Object Model (or "DOM") allows Vue to render components in its memory before updating the browser. Combined with the reactivity system, Vue can 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 hyperscript either through function calls or
JSX. Render functions allow applications to be built from
software components
Component-based software engineering (CBSE), also called component-based development (CBD), is a branch of software engineering that emphasizes the separation of concerns with respect to the wide-ranging functionality available throughout a giv ...
.
Reactivity
Vue features a reactivity system that uses plain
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
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:
* Automatically apply classes for
CSS
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone t ...
transitions and animations
* Integrate third-party CSS animation libraries, such as Animate.css
* Use JavaScript to directly manipulate the DOM during transition hooks
* Integrate third-party JavaScript animation libraries, such as
Velocity.js
When an element wrapped in a transition component is inserted or removed, this is what happens:
# 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.
# If the transition component provided JavaScript hooks, these hooks will be called at appropriate timings.
# 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 application
A single-page application (SPA) is a web application or website that interacts with the user by dynamically rewriting the current web page with new data from the web server, instead of the default method of a web browser loading entire new pages. ...
s (SPAs) 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 (it typically serves index.html or index.vue), 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 (whether by emailed link, refresh, or in-page links). Additionally, using a front-end router allows for the intentional transition of the browser path when certain browser events (i.e. clicks) 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 (navigating history), 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:
# Sets a front-end route at
websitename.com/user/
.
# Which will render in the User component defined in (const User...)
# 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
.
# This template (varying by the params passed into the router) will be rendered into
inside the DOM's div#app.
# 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
* Devtools – Browser devtools extension for debugging Vue.js applications
* Vue CLI – Standard Tooling for rapid Vue.js development
* Vue Loader – a webpack loader that allows the writing of Vue components in a format called Single-File Components (SFCs)
Official libraries
* Vue Router – The official router
* Vuex – Flux-inspired centralized state management
* Vue Server Renderer – Server-Side Rendering
* Pinia – New simple state management
See also
*
Comparison of JavaScript frameworks
This is a comparison of web frameworks for front-end web development that are heavily reliant on JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wi ...
*
React REACT or React may refer to:
Science and technology
* REACT (telescope), a telescope at Fenton Hill Observatory, New Mexico, US
Computing
* React (JavaScript library) , a JavaScript library for building user interfaces, from Facebook
** React Nat ...
*
AngularJS
AngularJS is a discontinued free and open-source JavaScript-based web framework for developing single-page applications. It was maintained mainly by Google and a community of individuals and corporations. It aimed to simplify both the developm ...
*
Angular
*
Quasar Framework
Quasar Framework (commonly referred to as Quasar; pronounced ) is an open-source Vue.js based framework for building apps, with a single codebase, and deploy it on the Web as a SPA, PWA, SSR, to a Mobile App, using Cordova for iOS & Android ...
*
JavaScript framework
A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build an ...
*
JavaScript library A JavaScript library is a library of pre-written JavaScript code that allows for easier development of JavaScript-based applications, especially for AJAX and other web-centric technologies.
Libraries
With the expanded demands for JavaScript, an e ...
*
Model–view–ViewModel
Model–view–viewmodel (MVVM) is an architectural pattern in computer software that facilitates the separation of the development of the graphical user interface (GUI; the ''view'')—be it via a markup language or GUI code—from the developme ...
*
Nuxt.js
Nuxt.js is a free and open source JavaScript library based on Vue.js, Node.js, Webpack and Babel.js. Nuxt is inspired by Next.js, which is a framework of similar purpose, based on React.js.
The framework is advertised as a "Meta-framework fo ...
Sources
References
External links
*
{{NodeJs
__FORCETOC__
Computer-related introductions in 2014
JavaScript web frameworks
Software frameworks
Software using the MIT license
Frameworks
A framework is a generic term commonly referring to an essential supporting structure which other things are built on top of.
Framework may refer to:
Computing
* Application framework, used to implement the structure of an application for an op ...
Web development