【发布时间】:2017-09-14 08:15:12
【问题描述】:
如何在下面的代码中的方法selectChange 中获取row.question_id 和option.AnswerMasterID 的值?我正在使用 Vue.js v2。
<div v-if="row.answer_input_type === 'Dropdown'">
<template v-for="answer in answers">
<template v-if="answer.AnswerTypeID === row.answer_type_id">
<select class="dropdown_cl" v-bind:disabled="row.is_enabled == 1 ? false : true" @change="selectChange(row.question_id, answer.AnswerDescription)">
<option v-for="option in answer.AnswerDescription" v-bind:value="option.AnswerMasterID" >{{option.AnswerDescription}}</option>
</select>
<p v-for="option in answer.AnswerDescription">{{option.AnswerMasterID}}</p>
</template>
</template>
</div>
我的方法如下:
selectChange: function (question_id, ans_master_id) {
alert(question_id + " " + ans_master_id)
},
我想获取option.AnswerMasterID 的值,它在内部循环中。
【问题讨论】:
-
你到底是什么意思?由于您将 2 个参数传递给
selectChange方法,因此您应该允许您的方法接受它们selectChange(id, desc) { console.log(id, desc)}并且它会记录触发方法时传递的数据。 -
看起来不错。问题是什么?
-
我想要 option.AnswerMasterID 的值
-
你可以按照我解释的方式得到它们......