【发布时间】:2021-07-07 20:25:02
【问题描述】:
我们有一个包含许多组件的 vue-js 页面 (@vue/cli 4.5.6),大部分都可以正常工作。一个组件正在做我不明白的事情:有两个单选框,一个在页面顶部,一个在底部。它们似乎完全不相关;这是一个
<template v-for="qSection in qSections">
...
<!--- loop to output individual questions here --->
<tr v-for = "question in qSection.questions">
<td>
{{ question.txt }}
<div v-if="question.incf">
<br/>
<textarea rows="2" cols = "80" :name= "question.cmt"
v-model="question.cmt" placeholder = "Comments here"
class="hideOnPrint"
/>
<div class="print-only"> {{ question.cmt }} </div>
</div>
</td>
<!-- okay, three more tds to hold radio box-->
<template v-for="icnt in [1,2,3]">
<td>
<label v-if="question.otherAns" class="other-ans-label">
{{ question.otherAns[icnt].txt }}
</label><br/><br/>
<input type = "radio" :name= "question.quesn" :value = "(icnt%3)"
v-model="question.answer"/>
</td>
</template>
</tr>
这是另一个
<template v-if="section.otype1 != 'Laboratory'">
<div class="hideOnPrint">
<input type = "radio" :name = "section.accept" :value="1"
v-model="section.accept"
>
{{acceptPhrase}}
</input>
<br/><br/>
<input type = "radio" :name = "section.accept" :value="0"
v-model="section.accept"
>
Investigation is incomplete. See comments.
</input><br/><br/>
</div>
</template>
所以发生的事情是单击底部区域中的单选按钮(仅适用于 value="1")un-单击顶部区域中的单选按钮(question.answer,以任何一个为准)被选中)。 根据开发者工具中的 Vue 应用程序,顶部区域数据仍然设置为:questions.answer = 2,比如说。事实上,如果我在那里将它设置为 1 并返回为 2,则该单选框会被正确地重新检查。
这是怎么发生的,我应该改变什么来解决它?或者我应该怎么做才能诊断它。谢谢!
我想举一个可行的例子,但不知道怎么做;页面的其余部分有很多部分。
【问题讨论】:
标签: vue.js vue-component