일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- html
- servlet
- API
- 자바문제
- 맥
- Mac
- nodejs
- ibatis
- Android
- FastAPI
- 자바
- Homebrew
- pyqt
- 반복문
- 대덕인재개발원
- 이클립스
- Java
- 배열
- Oracle
- crud
- JDBC
- Error
- ddit
- jsp
- 단축키
- python
- spring
- 컬렉션프레임워크
- 객체지향
- 생활코딩
Archives
- Today
- Total
romworld
[Vue.js]02 - 디렉티브, 이벤트 핸들링 본문
Home.vue
- v-model : 쌍방향 데이터 바인딩. 폼(form)에서 주로 사용. <input>,<select>,<textarea> 태그에만 사용가능하다.
- @click : 이벤트 핸들링 수행 -> onclick과 같음 methods를 호출해서 사용가능
- v-for : 배열 형식으로 표현할 때 사용, html 태그를 반복 출력
- watch : 데이터가 실시간으로 변경될 때 감지
- beforeCreate, created, beforeMount, mounted, beforeUpdate, updated, beforeDestroy, destroyed -> life cycle
- console로 찍어볼 때 set을 누르는 경우 beforeUpdate, updated만 찍히는 걸 알 수 있음
- 데이터에 접근할 때 html코드 안에서 접근하는 경우 {{ }} 중괄호 두개로 표현하고 element 안에서 attribute 적용을 할 때는 : 세미콜론으로 표현
- v-model="region" : selectBox에서 default 값으로 설정할 수 있음.
- @change : 이벤트를 걸 때 사용. methods를 통해 값을 전환시킬 수 있음
- v-if: 조건이 만족하면 데이터 렌더링을 해줌 => 즉 tableShow : false 인 경우 테이블이 보이지 않음.
- v-show: : v-if와 비슷하나 show는 데이터 렌더링이 다 됨. 다만 show&hide 처럼 보이거나 숨겨진다.
<template>
<div>
<h1>Welcome to {{title2}}!</h1>
<input type="text" v-model="input1"/>
<button type="button" @click="getData">Get</button>
<button type="button" @click="setData">Set</button>
<select class="form-control" v-model="region">
<option :key="i" :value="d.v" v-for="(d,i) in options">{{d.t}}</option>
</select>
</div>
</template>
<script>
export default {
data() {
return {
title:"오늘은 화요일",
title2:"Seoul",
input1:"abcdddddd",
options: [
{v:"S",t:"Seoul"},
{v:"J",t:"Jeju"},
{v:"B",t:"Busan"},
],
region: "J"
};
},
watch: {
input1() {
console.log(this.input1);
}
},
methods: {
getData() {
alert(this.input1);
},
setData() {
this.input1 = "12345";
}
},
beforeCreate(){
console.log("beforeCreate");
},
created(){
console.log("created");
},
beforeMount(){
console.log("beforeMount");
},
mounted(){
console.log("mounted");
},
beforeUpdate(){
console.log("beforeUpdate");
},
updated(){
console.log("updated");
},
beforeDestroy(){
console.log("beforeDestory");
},
destroyed(){
console.log("destroyed");
}
};
</script>
'etc' 카테고리의 다른 글
[MAC] Homebrew를 M2칩에 설치하기! (0) | 2023.05.31 |
---|---|
[Mac] 내가 보려고 만든 IntelliJ 단축키 (0) | 2023.05.11 |
[Mac] 내가 보려고 만든 VS Code 단축키 (0) | 2023.05.09 |
[Vue.js] 01 - Vue.js 설치 (VS code 사용) (0) | 2023.05.09 |
[node.js] 설치 (0) | 2023.05.08 |
Comments