<template> <view> <view> <view class="tkt_style" v-for="(item,index) in current_timu.right_answer_arr" :key="index"> <input type="text" placeholder="请输入答案" :value="current_timu.my_answer_arr[index]" @input="post_answer($event, index)"> </view> </view> <view class="tkt_button" :class="is_tiankong_sub ? 'duoxuan_checked' : 'duoxuan' " v-if="current_timu.right_answer_arr.length > 0 && !show_beiti" @tap="post_answer_req()"> {{is_tiankong_sub ? '提交成功' : '确认提交'}} </view> </view> </template> <script> export default { props: { current_timu: { type: Object, default: function() { return {} }, }, is_tiankong_sub: { type: Boolean, default: false, }, show_beiti: { type: Boolean, default: true, }, copy_user_answer: { type: Array, default: function() { return []; }, } }, watch: { current_timu: { handler(newVal, oldVal) {}, deep: true, immediate: true } }, methods: { // 提交答案 post_answer(item, index) { this.$emit('post_answer', item, index) if (this.is_tiankong_sub) { this.$emit('set_sub_button_style', 'is_tiankong_sub', false) } let timu = this.current_timu, my_answer_arr = this.current_timu.my_answer_arr; this.$set(my_answer_arr, index, item.detail.value) this.$set(timu, index, 'my_answer_arr', my_answer_arr) this.$set(timu, 'show_right_answer', true) if (timu.my_answer_arr.length > 0) { this.$set(timu, 'my_answer', timu.my_answer_arr.join('|')) } // if (timu.my_answer_arr.length > 0) { // this.$set(timu, 'user_answer', timu.my_answer_arr.join('|')) // } this.$emit('set_current_timu', timu) // let copy_user_answer_this = this.copy_user_answer; // if (copy_user_answer_this[this.current_timu.id]) { // copy_user_answer_this[this.current_timu.id] = timu.my_answer_arr // } // console.log(copy_user_answer_this) // this.$emit('set_copy_user_answer',copy_user_answer_this) }, post_answer_req() { this.$emit('post_answer_req', true) }, } } </script> <style> </style>