그래서 해결방안으로 찾은 것이 $event 이다.
<button class="btn" id="btn" @click="clickFollow">팔로우</button>
const btn = document.querySelector('btn') //id가 'btn'인 요소를 반환한다.
if(btn.innerText == 'Follow' ){ //버튼의 텍스트값 확인
btn.innerText = 'Unfollow' // 텍스트를 unfollow로 변경
}else{ // 반대일 경우 다시 변경
btn.innerText = 'Follow'
}
<button class="btn" @click="clickFollow($event)">follow
</button> //clickFollow를 호출할때 $event를 같이 넘겨준다
if(event.target.innerText == 'follow' ){
event.target.innerText = 'Unfollow'
event.target.style.backgroundColor='#FFFFFF'
}else{
event.target.innerText = 'follow'
event.target.style.backgroundColor='#50bcdf'
}