Vue.js (commonly referred to as Vue; pronounced /vjuː/, like view) is an open-source progressive JavaScript framework for building user interfaces.[3] Integration into projects that use other JavaScript libraries is made easy with Vue because it is designed to be incrementally adoptable. Also, Vue is a capable web application framework that is able to power advanced single-page applications.
Vue.js | |
---|---|
![]() | |
Original author(s) | Evan You |
Initial release | February 2014[1] |
Stable release | 2.2.2
/ March 9, 2017[2] |
Repository | |
Written in | JavaScript |
Platform | Cross-platform |
Size | 76 KB production 240 KB development |
Type | JavaScript library |
License | MIT License |
Website | vuejs![]() |
According to a 2016 JavaScript survey, Vue has an 89% developer satisfaction rating. Vue accumulates around 80 Github stars per day,[4][5] and is the 14th most starred project on Github of all time.[6]
History
Releases
2.0
Vue has always focused on staying light and fast, but 2.0 pushes it even further. The rendering layer is now based on a lightweight virtual-DOM implementation that improves initial rendering speed and memory consumption by up to 2~4x in most scenarios. The template-to-virtual-DOM compiler and the runtime can be separated, so you can pre-compile templates and ship your app with only the runtime, which is less than 12kb min+gzip (as a reference, React 15 is 44kb min+gzip).[7]
Features
Templates
Vue uses an HTML-based template syntax that allows you to declaratively bind the rendered DOM to the underlying Vue instance’s data. All Vue templates are valid HTML that can be parsed by spec-compliant browsers and HTML parsers. Under the hood, Vue compiles the templates into Virtual DOM render functions. Combined with the reactivity system, Vue is able to intelligently figure out the minimal amount of components to re-render and apply the minimal amount of DOM manipulations when the app state changes.
In Vue, you can use the template syntax or choose to directly write render functions using JSX. In order to do so just replace the template option with a render function.[8]
Reactivity
One of Vue’s most distinct features is the unobtrusive reactivity system. Models are just plain JavaScript objects. When you modify them, the view updates. It makes state management very simple and intuitive. Vue provides optimized re-rendering out of the box without you having to do anything. 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.[9]
Components
Components are one of the most powerful features of Vue. In a large application, it is necessary to divide the whole app into small, self-contained, and often reusable components to make development manageable. Components extend basic HTML elements to encapsulate reusable code. At a high level, components are custom elements that Vue’s compiler attaches behavior to. In Vue, a component is essentially a Vue instance with pre-defined options.[10]
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 transitions and animations
- integrate 3rd-party CSS animation libraries, such as Animate.css
- use JavaScript to directly manipulate the DOM during transition hooks
- integrate 3rd-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.[11][12]
Routing
Vue itself doesn’t come with routing. But there’s the vue-router package to help you out. It supports mapping nested routes to nested components and offers fine-grained transition control. Creating a Single-page Application with Vue + vue-router is dead simple. With Vue, we are already composing our application with components. When adding vue-router to the mix, all we need to do is map our components to the routes and let vue-router know where to render them.[13]
Development
Comparison with Other Frameworks
Supporting Libraries
See Also
References
- ^ "First Week of Launching Vue.js". Evan You.
- ^ "Vue.js Releases". Github.
- ^ "Introduction — Vue.js". Retrieved 2017-03-11.
- ^ "State Of JavaScript Survey Results: Front-end Frameworks". Retrieved 2017-03-11.
- ^ "Trending JavaScript Frameworks". Retrieved 2017-03-11.
{{cite web}}
: Cite has empty unknown parameter:|dead-url=
(help) - ^ "Most Starred Repositories". GitHub. Retrieved 2017-03-11.
{{cite web}}
: Cite has empty unknown parameter:|dead-url=
(help) - ^ "Announcing Vue.js 2.0". The Vue Point. 2016-04-27. Retrieved 2017-03-11.
- ^ "Template Syntax — Vue.js". Retrieved 2017-03-11.
- ^ "Reactivity in Depth — Vue.js". Retrieved 2017-03-11.
- ^ "Components — Vue.js". Retrieved 2017-03-11.
- ^ "Transition Effects — Vue.js". Retrieved 2017-03-11.
- ^ "Transitioning State — Vue.js". Retrieved 2017-03-11.
- ^ "Routing — Vue.js". Retrieved 2017-03-11.