학원/VueJS

26_Vue CLI

행수쌤 2023. 4. 30. 15:09
728x90
반응형

준비

      - NodeJS 설치

      - npm 설치 : cmd에 npm install @vue/cli --location=global

      - 프로젝트 생성 : cmd에 vue create 프로젝트명

      - 실행 : npm run serve

      - 종료 : ctrl + c

      - extentions에서 vue language features 설치

      - 배포버전 생성 : npm run build

Export

export {student}; 			//student를 내보내겠다(named export)
export default student;		//student를 기본값으로 내보내겠다.(default export)

Import

import {student} from 경로; 			//student로 export 된 것을 가져와 쓰겠다
import {student as 새이름} from 경로;	//student로 export된 것을 새 이름으로 쓰겠다
import student form 경로;		//경로에서 default export 된 것을 student라는 이름으로 쓰겠다
//파일명을 index.js로 하면 경로를 상위 폴더까지 작성 가능

Vuex

      - npm instal  vuex

      - utils -> vuex -> index.js 생성 후 {storage} export

      - main.js에서 import 후 app.use(storage);

Axios

      - utils -> axios -> index.js 생성 후 axios import, export 설정

      - main.js에서 import 후 app.config.globalProperties.$http = axios;로 등록

      - $http 로 사용(이름 변경 가능)

728x90
반응형