...
<div id="app">
<my-component></my-component>
<your-component></your-component>
<div>
...
<script>
Vue.componet('my-component', {
template: `<div id="app"><img src="./assets/logo.png"><h1>{{ msg }}</h1><h2>Essential Links</h2><ul><li><a href="https://vuejs.org" target="_blank">Core Docs</a></li><li><a href="https://forum.vuejs.org" target="_blank">Forum</a></li><li><a href="https://chat.vuejs.org" target="_blank">Community Chat</a></li><li><a href="https://twitter.com/vuejs" target="_blank">Twitter</a></li></ul><h2>Ecosystem</h2><ul><li><a href="http://router.vuejs.org/" target="_blank">vue-router</a></li><li><a href="http://vuex.vuejs.org/" target="_blank">vuex</a></li><li><a href="http://vue-loader.vuejs.org/" target="_blank">vue-loader</a></li><li><a href="https://github.com/vuejs/awesome-vue" target="_blank">awesome-vue</a></li></ul></div>`
});
Vue.componet('your-component', {
template: `<div id="app"><img src="./assets/logo.png"><h1>{{ msg }}</h1><h2>Essential Links</h2><ul><li><a href="https://vuejs.org" target="_blank">Core Docs</a></li><li><a href="https://forum.vuejs.org" target="_blank">Forum</a></li><li><a href="https://chat.vuejs.org" target="_blank">Community Chat</a></li><li><a href="https://twitter.com/vuejs" target="_blank">Twitter</a></li></ul></div>`
});
new Vue({
el:'#app',
data: {
message:'click this button'
}
});
</script>
...
<script>
ํ๊ทธ ์์์ HTML์ฝ๋๋ ๊ตฌ๋ฌธ ๊ฐ์กฐ๊ฐ ์ ์ฉ๋์ง ์๊ธฐ ๋๋ฌธ์ ์คํ์๋ฅผ ์ฐพ๊ธฐ๊ฐ ์ด๋ ต๋ค.์ฑ๊ธ ํ์ผ ์ปดํฌ๋ํธ๋?
.vue ํ์ผ ๊ธฐ๋ณธ ๊ตฌ์กฐ
<template>
<!-- HTML ํ๊ทธ ๋ด์ฉ -->
</template>
<script>
export default{
// ์๋ฐ์คํฌ๋ฆฝํธ ๋ด์ฉ
}
</script>
<style>
/* css ์คํ์ผ ๋ด์ฉ */
</style>
๋ทฐ CLI ์ค์น
npm install vue-cli -global
vue
๋ทฐ CLI ๋ช ๋ น์ด
ํ ํ๋ฆฟ ์ข ๋ฅ | ์ค๋ช |
---|---|
Vue init webpack | ๊ณ ๊ธ ์นํฉ ๊ธฐ๋ฅ์ ํ์ฉํ ํ๋ก์ ํธ ๊ตฌ์ฑ ๋ฐฉ์. ํ ์คํ , ๋ฌธ๋ฒ ๊ฒ์ฌ ๋ฑ์ ์ง์ |
Vue init webpack-simple | ์นํฉ ์ต์ ๊ธฐ๋ฅ์ ํ์ฉํ ํ๋ก์ ํธ ๊ตฌ์ฑ ๋ฐฉ์. ๋น ๋ฅธ ํ๋ฉด ํ๋กํ ํ์ดํ์ฉ |
Vue init browserify | ๊ณ ๊ธ ๋ธ๋ผ์ฐ์ ๋ฆฌํ์ด ๊ธฐ๋ฅ์ ํ์ฉํ ํ๋ก์ ํธ ๊ตฌ์ฑ ๋ฐฉ์. ํ ์คํ , ๋ฌธ๋ฒ ๊ฒ์ฌ ๋ฑ์ ์ง์ |
Vue init browserify-simple | ๋ธ๋ผ์ฐ์ ๋ฆฌํ์ด ์ต์ ๊ธฐ๋ฅ์ ํ์ฉํ ํ๋ก์ ํธ ๊ตฌ์ฑ ๋ฐฉ์. ๋น ๋ฅธ ํ๋ฉด ํ๋กํ ํ์ดํ์ฉ |
Vue init simple | ์ต์ ๋ทฐ ๊ธฐ๋ฅ๋ง ๋ค์ด๊ฐ HTML ํ์ผ 1๊ฐ ์์ฑ |
Vue init pwa | ์นํฉ ๊ธฐ๋ฐ์ ํ๋ก๊ทธ๋ ์๋ธ ์น ์ฑ(PWA, Progressive Web App) ๊ธฐ๋ฅ์ ์ง์ํ๋ ๋ทฐ ํ๋ก์ ํธ |
01.๋ทฐ ํ๋ก์ ํธ๋ฅผ ์์ฑํ ๋นํด๋๋ฅผ ์์ฑํ๊ณ ๋น ํด๋์์ cmd์ฐฝ์ ์ด์ด vue init webpack-simple
์
๋ ฅ
npm install
์
๋ ฅํ์ฌ ๋ทฐ ์ ํ๋ฆฌ์ผ์ด์
์ ๊ตฌ๋ํ๊ธฐ ์ํ ๊ด๋ จ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ๋ชจ๋ ๋ค์ด๋ก๋ ํ๋ค.
npm install
๋ช
๋ น์ด ์
๋ ฅ ๊ฒฐ๊ณผ ํ๋ฉดnpm run dev
๋ฅผ ์คํํ๋ฉด localhost:8080์ผ๋ก ์ ๊ทผํ์ฌ ์ ํ๋ฆฌ์ผ์ด์
์ ์คํํ ์ ์๋ค.npm run dev
์คํํ ๋ทฐ ์ ํ๋ฆฌ์ผ์ด์
์ด๊ธฐํ๋ฉดnpm run dev
๋ช
๋ น์ด ์
๋ ฅ ๊ฒฐ๊ณผ ํ๋ฉดhttp://loaclhost:8080/
์ ๊ตฌ๋๋๊ณ ์์์ ์๋ ค์ฃผ๋ฉด์ ์นํฉ ๊ฒฐ๊ณผ๊ฐ(output)์ด /dist/
์์ ์ ๊ณต๋ ์๋ค๋ ์๋ฏธ์ด๋ค.