Не работает input type="hidden" в vue.js. Что можно использовать вместо него?
Я новичок в vue поэтому не судите строго. В общем , я хочу сделать малое приложение с вопросами. На каждый вопрос есть три варианта ответа. Правильный ответ- я хотел хранить в скрытом инпуте для того чтобы его сравнивать с ответом пользователя. Но как я узнал в vue.js не поддерживается скрытые инпуты. Как мне быть в этом случае. Буду рад любой помощи!
<template>
<div>
<li v-for="question,index in questions">{{question.question}}
<div v-if="question.right_answer2==null">
<p class="text"></p>
<input type="hidden" :value="question.right_answer1" v-model="rightAnswer">
<input type="radio" :id="question.id" :value="question.answer1" v-model="radio">
<label >{{question.answer1}}</label>
<input type="radio" :id="question.id" :value="question.answer2" v-model="radio">
<label>{{question.answer2}}</label>
<input type="radio" :id="question.id" :value="question.answer3" v-model="radio">
<input type="radio" :id="question.id" :value="question.answer3">
<label >{{question.answer3}}</label>
<button v-on:click="checkRadio" type="button" >Ответить</button>
</div>
<div v-else>
<input type="checkbox" :id="question.id" :value="question.answer1" v-model="checkedNames">
<label >{{question.answer1}}</label>
<input type="checkbox" :id="question.id" :value="question.answer2" v-model="checkedNames">
<label >{{question.answer2}}</label>
<input type="checkbox" :id="question.id" :value="question.answer3" v-model="checkedNames">
<label >{{question.answer3}}</label>
<button v-on:click="checkChecked" type="button" >Ответить</button>
</div>
</li>
</div>
</template>
<script>
export default {
data: function () {
return {
questions:null,
checkedNames: [],
rightAnswer:'',
}
},
mounted() {
axios
.get('/api/v1/companies/index')
.then(response => (this.questions = response.data));
},
methods: {
checkRadio(){
let text=document.getElementById('text');
return this.radio==this.rightAnswer1 ? text.textContent="Правильный ответ" : text.textContent="Неправильный ответ";
}