# Node.js 설치 후 터미널에서 버전 확인 C:\Users\xeonmin>C:\Users\xeonmin>node --version v14.17.6C:\Users\xeonmin>npm --version 6.14.15C:\Users\xeonmin> # npm 명령어를 이용하여 Vue 설치 C:\Users\xeonmin>npm install -g @vue/cli(생략...)C:\Users\xeonmin>C:\Users\xeonmin>vue --version @vue/cli 4.5.13C:\Users\xeonmin>C:\Users\xeonmin>
# Vue 프로젝트 생성 D:\IdeaProjects>vue create dashboard Vue CLI v4.5.13 ✨ Creating project inD:\IdeaProjects\dashboard. ⚙️ Installing CLI plugins. This might take a while...[..............] \ fetchMetadata: sill resolveWithNewModule find-(생략...) found 34vulnerabilities(16 moderate,18 high) run `npm audit fix` to fix them, or `npm audit`for details ⚓ Running completion hooks... � Generating README.md... � Successfully created project dashboard. � Get started with the following commands: $ cd dashboard $ npm run serve # 설치 마지막에 안내된대로, 새로 생성한 프로젝트 내부로 이동하여($ cd dashboard), 프로젝트를 실행하자(npm run serve).D:\IdeaProjects>cd dashboard D:\IdeaProjects\dashboard>D:\IdeaProjects\dashboard>npm run serve > dashboard@0.1.0 serve D:\IdeaProjects\dashboard > vue-cli-service serve INFO Starting development server...98% after emitting CopyPlugin DONE Compiled successfully in2555ms 오후 5:25:14 App running at:- Local: http://localhost:8080/- Network: http://10.60.1.41:8080/ Note that the development build is not optimized. To create a production build, run npm run build.
뷰 인스턴스의 옵션 속성으로는, data, el, template, component, 뷰 라이프사이클(beforeCreate, created, beforeMount,...) 등의 속성을 사용할 수 있다.
뷰 라이프사이클
인스턴스의 상태에 따라 호출할 수 있는 속성을 라이프사이클 이라고 한다.
존재하지 않는 이미지입니다.
# 라이프 사이클 적용 예시 <div id="app">{{message}}</div><script>classVue({ el:'#app', data:{ message:'Hello from Vue'},beforeCreate:function(){ console.log("beforeCreate")},updated:function(){ console.log("updated")}</script>
컴포넌트
Component란 조합하여 화면을 구성할 수 있는 블록(화면의 특정 영역)을 의미한다.
컴포넌트는 여러 인스턴스에서 공통적으로 사용할 수 있는 전역 컴포넌트와, 특정 인스턴스에서만 유효한 범위를 갖는 지역 컴포넌트로 나누어진다.
# 전역 컴포넌트 / 지역 컴포넌트 선언 ...<div class="chart"><global></global><local></local></div>...<script>// 전역 컴포넌트 등록 Vue.component('global',{ template:'<div>전역 컴포넌트</div>'});// 지역 컴포넌트 등록var cmp ={ template:'<div>지역 컴포넌트</div>'} Vue.component('global',{ el:'#app', components:{'local': cmp }});</script>