-
vue3.js 세팅하기(vue-router)웹/vue 2021. 6. 8. 12:16반응형
vue.js vue.js cli 설정 하는 방법을 알아보겠습니다.
npm install -g @vue/cli // cli3 버전 npm install vue-cli //cli2 버전
cli툴을 설치해주세요!
vue create {project명} //3.x vue init {탬플릿} {파일 경로} //2.x
프로젝트 생성
//3.x npm run serve yarn serve //2.x npm run dev yarn dev
로컬 실행 방법
cli2 vs cli3
cli2는 기본 세팅이 없음, 탬플릿 선택해야됨, webpack이 밖에 들어나 있음, node module이 자동설치 안됨
cl3는 기본 설정 있음,탬플릿 따로 없음,내장 webpack, node module자동 설치됨
(자세한건 제가 참고한 블로그를 봐주세요ㅎㅎ)
vue-router
설치
npm i vue-router@next --save //3.x npm i vue-router //2.x
vue3버전으로 만들고 그냥 vue-router를 설치하셨다면 uninstall하신뒤에 3.x로 설치하세요! (vue3 기능이 작동을 안합니다!)
설정하기
간단히 Lading page와 router를 만들었습니다 /router/index.js
import { createRouter, createWebHistory } from "vue-router"; const routes = [ { path: "/", name: "home", component: () => import("../page/Lading"), }, ]; const router = createRouter({ history: createWebHistory(),//2.x대를 설치하시면 작동을 안합니다. routes, }); export default router;
/page/landing.vue
<template> <div> <p>home page</p> </div> </template> <script> export default { } </script> <style> </style>
(간단하게 설정했습니다)
/main.js
import { createApp } from "vue"; import App from "./App.vue"; import Router from "./router"; const app = createApp(App); app.use(Router); app.mount("#app");
이렇게 설정하시고 실행하면 이렇게 나옵니다.
vue-공식사이트
시작하기 — Vue.js
Vue.js - 프로그레시브 자바스크립트 프레임워크
kr.vuejs.org
참고 블로그 및 사이트
CLI | Cracking Vue.js (joshua1988.github.io)
CLI | Cracking Vue.js
뷰 CLI 뷰 CLI는 뷰로 빠르게 프로젝트를 구성하고 프로토 타이핑을 하고 싶을 때 사용하는 CLI 도구입니다. 최신 버전은 3.x이며 책에서는 2.9 버전을 기준으로 설명하였습니다. 뷰 CLI 설치 뷰 CLI를
joshua1988.github.io
Vue Cli 초기 세팅
Vue CLI는 Vue 프로젝트를 개발할 수 있게 해주는 아주 유용한 도구이며, 여기서 CLI란 Command Line Interface의 약자로서 타이핑으로 명령어를 입력하여 원하는 바를 실행시키는 도구를 말한다. 윈도우
velog.io
vue3 미리 살펴보기
vue3 가 release 되기전에 한번 살펴보자!
velog.io
Vue router with Vue 3 raises the error "Uncaught TypeError: Object(...) is not a function"
Created a simple Vue project using the CLI: vue create my-project Wanted to add two pages, so installed the latest version of vue-router (which is currently v3.4.8) and followed the vue mastery
stackoverflow.com
반응형'웹 > vue' 카테고리의 다른 글
vue Option-3 정리(methods vs computed vs watch) (0) 2021.09.09 vue options정리-2 (props) (0) 2021.09.08 vue options정리-1 (data) (0) 2021.09.08 Vue3 Provide / Inject 정리 (0) 2021.09.07