Skip to content

Commit

Permalink
Add ref attribution in input tag to focusing after typing
Browse files Browse the repository at this point in the history
  • Loading branch information
chihyeonwon committed Oct 30, 2021
1 parent 0c991f5 commit c762957
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ first }} 곱하기 {{ second }} 는?
</div>
<form v-on:submit="onSubmitForm">
<input type="number" v-model="inputValue">
<input type="number" v-model="inputValue" ref="answer">
<button type="submit">입력</button>
</form>
<div id="result">
Expand Down Expand Up @@ -34,8 +34,10 @@ export default {
this.first = Math.ceil(Math.random() * 9);
this.second = Math.ceil(Math.random() * 9);
this.inputValue = '';
// ref 속성으로 커서 깜빡임을 유지
this.$refs.answer.focus();
} else {
this.result='';
this.result='오답';
this.inputValue='';
}
},
Expand Down

0 comments on commit c762957

Please sign in to comment.