Intro to Vue.js
What, Why, and How
1. What is Vue.js?
a progressive framework for building user interfaces
1. Front End
2. SPA (Single Page Application)
A web application composed of a single page
Instead of receiving the necessary data as HTML from the server side during page transitions (no server-side rendering), it dynamically renders by receiving only the necessary data from the server as JSON
client side rendering!
Since the client holds all the HTML and only requests necessary data from the server side, receiving it as JSON, the speed of composing the screen is faster compared to traditional applications
Advantages
Page transitions are fast because there is no need to render the entire screen each time.
The processing is efficient because only the necessary data for the screen is received and rendered.
It is convenient for users to use.
Disadvantages
When loading the initial screen, it takes time because all screens must be prepared in advance.
It takes more time and is more complex to implement the application.
Reference: https://velog.io/@josworks27/SPA-%EA%B0%9C%EB%85%90
3. Client Side Rendering

4. MVVN (Model View ViewModel) Pattern

Structure
Model
The part that handles the data used in the application and its processing
View
The UI part that is shown to the user.
View Model
A Model created for the View, to represent the View
A Model for representing the View, and the part that processes data for displaying the View
Operation Sequence
User Actions come through the View
When an Action enters the View, the Action is delivered to the View Model using the Command pattern
The View Model requests data from the Model
The Model responds with the requested data to the View Model
The View Model processes and stores the received data
The View displays the screen through Data Binding with the View Model
Advantages
The MVVM pattern has no dependency between View and Model
It is also a design pattern that eliminates the dependency between View and View Model using the Command pattern and Data Binding
Since each part is independent, it can be developed in a modular fashion
Source: https://beomy.tistory.com/43 [beomy]
Vue.js is a View-layer library corresponding to the ViewModel layer of the MVVM pattern
5. Reactive
Vue vs React
Similarities
Utilizes a Virtual DOM
Provides reactive and composable components
Focuses only on the
core library, withcompanion librariesfor routing and global state management
+
Comparison of Vue.js with other frameworks
https://kr.vuejs.org/v2/guide/comparison.html
2. Why Vue.js?
Easy to learn!
$ (Cost savings)
Client Side Rendering
UX improvement
Asynchronous / SPA
Advantages of frameworks (franchise) (DX improvement - Developer Experience improvement)
No etc, focus and selection
Easy maintenance
Community and library
3. How?
Setups
VS Code
Install
Vetur
Chrome Web Store
Vue.js devtoolsSelect the following two options

image-20200525103628912
CDN
(For now) Use the development version above
4-1. data attribute
data attributeDefines the data to be displayed on the screen
ex)
01_data.html
4-2. Interpolation
ex)
02_interpolation.html
4-3. v-text
v-textSame as Vanilla JS's DomElement.innerText
Everything starting with the v- prefix is called a directive
ex)
03_v-text.html
4-4. v-if
v-ifIf the if evaluation is false, it does not appear on the screen
ex)
04_v-if.html
4-5. v-if, v-else-if, v-else
v-if, v-else-if, v-elseex)
05_v-if-elseif-else.html
4-6. v-for
v-forex)
06_v-for.html
4-7. v-bind
v-bindUsed to connect standard HTML attributes with the Vue Instance (+ more)
v-bind:can be abbreviated as:!
ex)
07_v-bind.html
4-8. methods attribute
methods attributeex)
08_methods.html
4-9 v-on
v-onUsed to register a listener
v-on:can be abbreviated as@!
ex)
09_v-on.html
4-10. v-model
v-modelTwo-way binding only available for input, select, and textarea
You can create two-way data bindings on form input and textarea elements using the
v-modeldirectivev-modelis essentially "syntax sugar" that updates data on user input eventsv-modelignores the initialvalue,checked, andselectedattributes of all form elementsIt always treats the Vue instance data as the source of truth
You should declare the initial value in JavaScript inside the component's
dataoption!
ex)
10_v-model.html
4-11. v-show
v-showv-if is advantageous when the evaluation (t/f) does not change frequently
=> Low initial rendering cost
v-show is good when the evaluation (t/f) changes frequently
=> Low toggle cost
v-show has it already prepared in the DOM, just with display set to none!
ex)
11_v-show.html
+
Lodash
A modern JavaScript utility library delivering modularity, performance & extras.
CDN
Last updated