๋ฐ์ํ Vue.js15 [Vue.js] vue-router๋ฅผ ์ฌ์ฉํ๋ ์ฌ๋ฌ ๊ฐ์ง ๋ฐฉ๋ฒ 1. import Vue from 'vue'; import VueRouter from 'vue-router'; import Home from '../components/Home.vue' import About from '../components/About.vue' Vue.use(VueRouter); const routes = [ { path: "/home", name: "Home", component: Home }, { path: "/about", name: "About", component: About }, ]; const router = new VueRouter({ mode: 'history', base: process.env.BASE_URL, routes }) export default router.. 2021. 10. 25. [Vue.js] vue-router ์ด๋? โ๏ธ vue-router ๋? ๋ผ์ฐํ ์ ๊ฐ๋จํ ํด์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ vue-router๋ SPA๋ฅผ ๋ง๋๋ ๊ฒ์ ์ฉ์ดํ๊ฒ ํด์ค๋ค. ์ค์น ๋ฐฉ๋ฒ ํ๋ก์ ํธ๊ฐ ์๋ ๊ฒฝ๋ก๋ก ๊ฐ์ terminal์ ์๋์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ๋ค. npm install vue-router ์ค์น๋ฅผ ํ๋ฉด package.json์ dependencies์ ์๋์ ๊ฐ์ ๋ฌธ๊ตฌ๊ฐ ์๋ก ์๊ธด๋ค. router์ ์ฌ์ฉํ ๋์๋ src ํด๋ ์๋์ 'router'๋ผ๋ ํด๋๋ฅผ ์์ฑํ๊ณ ๊ทธ ์์ index.js๋ผ๋ ํ์ผ์ ๋ง๋ ๋ค. ์ด๋ ๊ฒ ๋ง๋ค์๊ณ ํ ๊ฒ์ ์ฝ์์ด๋ผ๊ณ ํ๋ค. src/router/index.js import Vue from 'vue'; import VueRouter from 'vue-router'; import Home from '../componen.. 2021. 10. 25. node install ์ ๊ถํ ์ค๋ฅ ๋ฐ์ npm install๋ก ๋ค์์ ๋ช ๋ น์ด์ฒ๋ผ Vue.js๋ฅผ ์ค์นํ๋ ค๊ณ ํ๋ฉด npm install -g @vue/cli node_modules์ ๋ํ ๊ถํ์ด ์๋ค๋ ERROR ๋ฌธ๊ตฌ๋ฅผ ๋ณด์ค ์๋ ์๋ค.. ๋นํฉํ์ง๋ง๊ณ ๋ค์์ ๋ช ๋ น์ด๋ฅผ ์ ๋ ฅํ๊ณ sudo chown -R $(whoami) /usr/local/lib/node_modules ๋น๋ฐ๋ฒํธ๋ฅผ ์ ๋ ฅํ๋ผ๋ ์ฐฝ์ด ๋จ๋ฉด ๋น๋ฐ๋ฒํธ๋ฅผ ์ ๋ ฅํ๋ฉด ๋! ๋ค์ ์ค์นํ์๋ฉด ์ ๋ฉ๋๋ค ใ ใ 2021. 10. 22. ์ด์ 1 2 3 ๋ค์ ๋ฐ์ํ