단어 시험 만들기
// spanish.vue
<template>
<div>
<br />
<form v-on:submit="test">
<div v-if="hide">
{{word.day1[numberTest][1]}}
</div>
<br />
<input type="text" v-model="value" />
<button type="submit">입력</button>
</form>
<div v-if="stop">
맞은 개수 : {{yes}} <br />
틀린 개수 : {{no}} <br />
</div>
<tr v-for="(stupid, index) in stupid" v-if="stop">
오답 : : {{stupid}}
</tr>
<button v-on:click="show"> 보여줭!!</button>
<tr v-for="(fail, index) in check" v-if="master">
정답 : {{index+1}} : {{fail[0]}} : {{fail[1]}}
</tr>
</div>
</template>
<script>
import word from '../json/word.json'
export default {
data(){
return {
word: word,
value: '',
numberTest: 0,
yes:0,
no:0,
stop: false,
hide: true,
check: [],
stupid: [],
master: false
}
},
methods:{
test(e){
e.preventDefault();
if(this.word.day1[this.numberTest][0] === this.value){
this.numberTest++;
this.yes++;
if(this.numberTest === 10){
this.finished()
}
} else {
this.check.push(this.word.day1[this.numberTest])
this.stupid.push(this.value)
this.numberTest++;
this.no++
if(this.numberTest === 10){
this.finished()
}
}
},
finished(){
this.stop = true;
this.numberTest = 0;
this.hide = false;
},
show(e){
e.preventDefault();
this.master = true;
}
}
}
</script>
<style scoped>
</style>
'Vue-프로젝트' 카테고리의 다른 글
vue-프로젝트 chart.js(2)(5일차) (0) | 2020.04.09 |
---|---|
vue-프로젝트 chart.js(4일차) (0) | 2020.04.08 |
vue-프로젝트 : 날씨크롤링(3일차) (0) | 2020.04.06 |
vue-프로젝트 : 라우터 설정(1일차) (0) | 2020.03.28 |
Vue-프로젝트 계획 (0) | 2020.03.28 |