基于数组的无线电输入列表问题
Problem with listing of radio inputs based on array
在我的 Laravel 2.6 / 应用程序中,我需要显示基于数组的无线电输入列表:
customerAccountTypeValueArray::[ { "key": "I", "label": "Individual" }, { "key": "B", "label": "Business" } ]
我这样做:
<div class="custom-control custom-radio m-3" v-for="nextCustomerAccountTypeValue, index in customerAccountTypeValueArray"
:key="nextCustomerAccountTypeValue.key">
<input
:id="'customer_account_type_' + nextCustomerAccountTypeValue.key"
type="radio"
name="radio_account_type"
class="custom-control-input"
v-model="customerRow.account_type"
:value="customerRow.account_type"
>
<label class="custom-control-label" :for="'customer_account_type_' + nextCustomerAccountTypeValue.key">{{ nextCustomerAccountTypeValue.label}}</label>
...
where customerRow is defined as :
customerRow: {
account_type: '',
...
结果我看到了我的无线电输入,但是选择任何无线电输入 customerRow.account_type 值都没有改变。
如何解决?
替换
:value="customerRow.account_type"
和
:value="nextCustomerAccountTypeValue.key"
它应该可以工作。
在我的 Laravel 2.6 / 应用程序中,我需要显示基于数组的无线电输入列表:
customerAccountTypeValueArray::[ { "key": "I", "label": "Individual" }, { "key": "B", "label": "Business" } ]
我这样做:
<div class="custom-control custom-radio m-3" v-for="nextCustomerAccountTypeValue, index in customerAccountTypeValueArray"
:key="nextCustomerAccountTypeValue.key">
<input
:id="'customer_account_type_' + nextCustomerAccountTypeValue.key"
type="radio"
name="radio_account_type"
class="custom-control-input"
v-model="customerRow.account_type"
:value="customerRow.account_type"
>
<label class="custom-control-label" :for="'customer_account_type_' + nextCustomerAccountTypeValue.key">{{ nextCustomerAccountTypeValue.label}}</label>
...
where customerRow is defined as :
customerRow: {
account_type: '',
...
结果我看到了我的无线电输入,但是选择任何无线电输入 customerRow.account_type 值都没有改变。
如何解决?
替换
:value="customerRow.account_type"
和
:value="nextCustomerAccountTypeValue.key"
它应该可以工作。