Vue v-change 이벤트

박경준·2021년 11월 3일
0

vue beginner

목록 보기
8/18

v-change 디렉티브

v-change 디렉티브는 @change로도 사용 가능하다.

change는 select와 가장 많이 쓰이며, 사용자가 select에서 option을 바꿀때마다 트리거 됨.

// /views/EventChange
<template>
<select v-model="selectedValue" @change="changeSelect">
   <option value="서울">서울</option>
   <option value="부산">부산</option>
   <option value="제주">제주</option>
 </select>
</template>
<script>
export default {
 data() {
   return {
     selectedValue: ''
   };
  },
  methods: {
    changeSelect(){
      alert(this.selectedValue);
    }
  }
}
</script>
profile
빠굥

0개의 댓글