Vue

1 minute read

Vue

  • vuy-cli
    일반적인 vue객체에선 data:{}를 사용하지만 component에서는 data(){

    } 형식으로 이용

210513(목) vuecli오후

@vue/cli 실행환경구축 cdn을 이용하지 않음

  • NodeJS설치 - LTS버전(NPM과 같이 설치됨).
  • NPM을 이용한 @vue/cli설치

  • NPM(node package manager):js에서의 maven이라 생각
C:\Users\seong>node -v
v14.17.0

C:\Users\seong>npm -v
6.14.13
설치완료

NPM명령어

- npm init:새로운 프로젝트나 패키지 만들 때 사용(package.json 생성)
새로 패키지를 추가할 때
-1. npm install package:생성되는 위치에서만 사용 가능한 패키지로 설치
-2. npm install -g package: 글로벌 패키지에 추가. 모든 프로젝트에서 사용가능한 패키지로 설치
C:\Users\seong\OneDrive\바탕 화면\ssafy\npmtest>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (npmtest) test
version: (1.0.0)
description: test for npm
entry point: (index.js) --> 시작하는 파일
test command:
git repository: --> git이랑 연동
keywords: npm test
author: cse
license: (ISC)
About to write to C:\Users\seong\OneDrive\바탕 화면\ssafy\npmtest\package.json:

{
  "name": "test",
  "version": "1.0.0",
  "description": "test for npm",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [
    "npm",
    "test"
  ],
  "author": "cse",
  "license": "ISC"
}

vue-cli

npm i -g @vue/cli
계속 사용할것이기 때문에 -g
설치 후
C:\Users\seong\OneDrive\바탕 화면\ssafy\npmtest>vue -V
@vue/cli 4.5.13

@vue/cli 프로젝트 생성

- vue create <project-name>
default vue2 -> vuex, router가 없으므로
->manually select features
router,vuex 선택
2.x
history mode Y
ESLint + Prettier
Lint on save or commit?
in package.json(설정파일을 따로 만들것인지 package.json에서 함께 관리할지)

- 실행: npm run serve

Updated: