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

3. Client Side Rendering

image-20200525101243092

4. MVVN (Model View ViewModel) Pattern

image-20200525101419720
  • 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/43arrow-up-right [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, with companion libraries for routing and global state management

+

Comparison of Vue.js with other frameworks

https://kr.vuejs.org/v2/guide/comparison.htmlarrow-up-right

2. Why Vue.js?

  1. Easy to learn!

  2. $ (Cost savings)

    • Client Side Rendering

  3. UX improvement

    • Asynchronous / SPA

  4. 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 devtools

      • Select the following two options

      image-20200525103628912
  • CDN

    • (For now) Use the development version above

4-1. data attribute

  • Defines the data to be displayed on the screen

ex)

01_data.html

4-2. Interpolation

ex)

02_interpolation.html

4-3. v-text

  • Same 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

  • If 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

ex)

05_v-if-elseif-else.html

4-6. v-for

ex)

06_v-for.html

4-7. v-bind

  • Used 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

ex)

08_methods.html

4-9 v-on

  • Used to register a listener

  • v-on: can be abbreviated as @!

ex)

09_v-on.html

4-10. v-model

Two-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-model directive

  • v-model is essentially "syntax sugar" that updates data on user input events

  • v-model ignores the initial value, checked, and selected attributes of all form elements

    • It always treats the Vue instance data as the source of truth

    • You should declare the initial value in JavaScript inside the component's data option!

ex)

10_v-model.html

4-11. v-show

  • v-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.

https://lodash.com/arrow-up-right

CDN

Last updated