VueJS – JavaScript Framework – DEV Community

VueJS – JavaScript Framework – DEV Community


Image description



What is Vue?

Vue is a JavaScript framework for building UIs. It builds on top of standard HTML, CSS, and JavaScript.



Single-File Components

In most build-tool-enabled Vue projects, we author Vue components using an HTML-like file format called Single-File Component (also known as *.vue files, abbreviated as SFC). A Vue SFC, as the name suggests, encapsulates the component’s logic (JavaScript), template (HTML), and styles (CSS) in a single file. Here’s the previous example, written in SFC format:






Enter fullscreen mode

Exit fullscreen mode



API Styles

Vue components can be authored in two different API styles: Options API and Composition API.

Options API
With Options API, we define a component’s logic using an object of options such as data, methods, and mounted. Properties defined by options are exposed on this inside functions, which points to the component instance:




Enter fullscreen mode

Exit fullscreen mode

Composition API
With Composition API, we define a component’s logic using imported API functions.

Here is the same component, with the exact same template, but using Composition API instead:




Enter fullscreen mode

Exit fullscreen mode



*Which to choose?



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *