20180508_Vuejs - denlyou/AIL GitHub Wiki
๊ณต์ ํํ์ด์ง => https://vuejs.org/
์์ํ๊ธฐ ๊ฐ์ด๋(ํ๊ธ) => https://kr.vuejs.org/v2/guide/index.html
- front-end javascript framework
- ์ ์ง์ ์ผ๋ก ์ ์ฉ ๊ฐ๋ฅํ ํ๋ ์์ํฌ (progressive frameworks)
- MVVM ํจํด์ ์ ์ฉํ UI Library
- Component ๊ธฐ๋ฐ์ ํ๋ ์์ํฌ (์์ฆ ๋์ธ! ์ต๊ทค๋ฌ, ๋ฆฌ์ํธ๋ ์ปดํฌ๋ํธ ๊ธฐ๋ฐ)
- ์ต๊ทค๋ฌ(2way Data Binding)์ ๋ฆฌ์ํธ(1way Data Flow)์ ์ฅ์ ์ ๋๋ฃจ ๊ฐ์ถค
- node.js๋ฅผ ์ฌ์ฉํ๋ฉด ์ข์~
- chrome์ ๋๋ฒ๊ทธ์ฉ extension => vue.js devtools ๊ฒ์ ํ ์ค์น
- Vue.js๋ฅผ ์ฌ์ฉํ๋ ๊ธฐ๋ณธ ๋จ์
new Vue({ /* ... */ });
- Example
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Vue Sample</title>
</head>
<body>
<div id="app">
{{ message }}
</div>
<script src="https://unpkg.com/vue"></script>
<script type="text/javascript">
var app = new Vue({
el: '#app'
, data: {
message : "Hello vue.js!"
}
});
</script>
</body>
</html>
- ์ธ์คํด์ค์ ์ ํจ๋ฒ์ : el๋ก ์ง์ ํ DOM ์์ ๋ด๋ถ
- beforeCreate
- created
- beforeMount
- mounted
- befroeUpdate
- updated
- beforeDestory
- destoryed
- ํ๋ฉด์ ํน์ ์์ญ์ ์ชผ๊ฐ ๋จ์(?!)
- ์ ์ญ ์ปดํฌ๋ํธ์ ์ง์ญ ์ปดํฌ๋ํธ
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="utf-8">
<title>Vue Sample</title>
</head>
<body>
<div id="app">
<button>์ปดํฌ๋ํธ ๋ฑ๋ก</button>
<my-component></my-component>
<my-local-compo></my-local-compo>
</div>
<div id="app2">
<button>์ปดํฌ๋ํธ ๋ฑ๋ก</button>
<my-component></my-component>
<my-local-compo></my-local-compo>
</div>
<script src="https://unpkg.com/vue" charset="utf-8"></script>
<script type="text/javascript">
Vue.component("my-component", {
template: "<div>์ ์ญ ์ปดํฌ๋ํธ๊ฐ ๋ฑ๋ก ๋์์ต๋๋ค.</div>"
});
new Vue({
el: "#app"
, components: {
"my-local-compo" : {
template : "<div>์ง์ญ ์ปดํฌ๋ํธ๊ฐ ๋ฑ๋ก ๋์์ต๋๋ค.</div>"
}
}
});
new Vue({
el: "#app2"
// , components: {
// "my-local-compo" : {
// template : "<div>์ง์ญ ์ปดํฌ๋ํธ2๊ฐ ๋ฑ๋ก ๋์์ต๋๋ค.</div>"
// }
// }
});
</script>
</body>
</html>
- ๊ฐ ์ปดํฌ๋ํธ์ ๋ฉค๋ฒ ๊ฐ๋ค์ ๊ฐ๊ฐ์ scope๋ฅผ ๊ฐ์ง, ๋ฐ๋ผ์ ์๋ก ๊ณต์ ๋์ง ์์(ํธ์ถ ๋ถ๊ฐ)
- (๊ณ์ ๊ณต๋ถ์ค...)