[Vue] v-model

유지나·2023년 5월 4일
0

v-model_

사용자가 입력한 값을 아래의 변수에 바로 연결해 줌

방법1

event.target :대상
event.target.value : 대상에 입력된 값
month: 값을 할당 할 변수

<input @input="month=$event.target.value"/>

방법2

v-model을 이용한 데이터 바인딩

<input v-model="month"/>

방법3

v-model, select를 이용한 데이터 바인딩

<select v-model="month">
	<option>1</option>
    <option>2</option>
    <option>3</option>
    <option>4</option>
</select>

방법4

v-model, checkbox를 이용한 데이터 바인딩

  • checkbox는 boolean타입으로 값이 저장됨
<input type="checkbox" v-model="month"/>
profile
지르나르

0개의 댓글