Skip to Content
Vue 학습
book

Vue 학습

by Maya Shavin
May 2025
Beginner to intermediate
350 pages
5h 20m
Korean
O'Reilly Media, Inc.
Content preview from Vue 학습

2장. Vue 작동 방식: 기본 사항

이 작품은 AI를 사용하여 번역되었습니다. 여러분의 피드백과 의견을 환영합니다: translation-feedback@oreilly.com

이전 장에서는 Vue 애플리케이션을 구축하는 데 필수적인 도구를 배우고 첫 번째 Vue 애플리케이션을 생성하여 다음 단계인 Vue 코드 작성을 통한 Vue 작동 방식 학습을 준비했습니다.

이 장에서는 가상 DOM(가상 문서 객체 모델)의 개념과 Vue 옵션 API를 사용한 Vue 컴포넌트 작성의 기초를 소개합니다. 또한 추가 Vue 지시어와 Vue 반응성 메커니즘에 대해서도 살펴봅니다. 이 장이 끝나면 Vue의 작동 방식을 이해하고 애플리케이션에서 사용할 Vue 컴포넌트를 작성하고 등록할 수 있게 됩니다.

가상 DOM 내부

Vue는 DOM(문서 객체 모델)과 직접 작동하지 않습니다. 대신 가상 DOM을 구현하여 런타임에 애플리케이션의 성능을 최적화합니다.

가상 DOM의 작동 방식에 대한 확실한 이해를 돕기 위해 먼저 DOM의 개념부터 살펴봅니다.

DOM은 웹에서 HTML(또는 XML) 문서 콘텐츠를 인메모리 트리와 같은 데이터 구조의 형태로 나타냅니다( 그림 2-1 참조). 웹 페이지와 실제 프로그래밍 코드(예: JavaScript)를 연결하는 프로그래밍 인터페이스 역할을 합니다. HTML 문서에서 <div> 또는 <section> 과 같은 태그는 프로그래밍 노드 및 객체 로 표현됩니다.

An image illustrated different HTML elements connected, distributing by nesting levels
그림 2-1. DOM 트리의 예

브라우저가 HTML 문서를 파싱한 후 DOM을 즉시 상호작용에 사용할 수 있습니다. 레이아웃이 변경되면 브라우저는 백그라운드에서 DOM을 지속적으로 페인팅하고 다시 칠합니다. 이 프로세스를 파싱이라고 하고, DOM 화면 래스터화 또는 픽셀 대 화면 파이프라인을 페인팅이라고 합니다. 그림 2-2는 래스터화가 어떻게 작동하는지 보여줍니다:

An image illustrated a flow diagram consisting of five major steps, including parsing HTML and CSS code, calculating the CSS styles for elements, planning for screen layout, then painting the visual elements, and finally applying the composition layer on them on the browsers. It also highlights where repaint and reflow happens whenever layout changes happen.
그림 2-2. 브라우저 래스터화 프로세스

레이아웃 업데이트 문제

각 페인트는 브라우저의 성능에 많은 비용이 듭니다. DOM은 많은 노드로 구성될 수 있으므로 단일 또는 여러 노드를 쿼리하고 업데이트하는 데 많은비용이 들 수 있습니다.

다음은 DOM에 있는 li 요소 목록의 간단한 예시입니다:

<ul class="list" id="todo-list">
  <li class="list-item">To do item 1</li>
  <li class="list-item">To do item 2</li>
  <!--so on…-->
</ul>

li 요소를 추가/제거하거나 콘텐츠를 수정하려면 document.getElementById (또는 document.getElementsByClassName ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

MLOps 도입 가이드

MLOps 도입 가이드

데이터이쿠
DevOps를 위한 Python

DevOps를 위한 Python

Noah Gift, Kennedy Behrman, Alfredo Deza, Grig Gheorghiu

Publisher Resources

ISBN: 9798341654730