周爱迪
周爱迪
  • 发布:2020-02-06 15:38
  • 更新:2022-07-20 15:47
  • 阅读:3327

uni-app页面存在多个radio-group时无法获取是哪个按钮组被点击

分类:uni-app

<template>
<view>
<view class="uni-list">
<radio-group @change="radioChange" v-for="(radioGroup, i) in radioGroups">
<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in items" :key="item.value">
<view>
<radio :value="item.value" :checked="index === current" />
</view>
<view>{{item.name}}</view>
</label>
</radio-group>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: 'radio 单选框',
radioGroups:[{
name: '2'
},
{
name: '1',
}],
items: [{
value: 'USA',
name: '美'
},
{
value: 'CHN',
name: '中',
checked: 'true'
}
],
current: 0
}
},
methods: {
radioChange(evt) {
console.log(evt);
}
}
}
</script>

<style>
.uni-list-cell {
justify-content: flex-start
}
</style>

2020-02-06 15:38 负责人:无 分享
已邀请:
8***@qq.com

8***@qq.com

<radio-group :data-id='index' @change="changeStatus">
<label>
<radio color='#F58C3B' value="1" /><text>开售</text>
<radio color='#F58C3B' value="2" style="margin-left: 10px;"/><text>预售</text>
</label>
</radio-group>

jason王

jason王

我也遇到同样的问题,加id和name或者ref都没用。最后解决了吗

2***@qq.com

2***@qq.com - qiulanbook

加:data-id='index'无效

该问题目前已经被锁定, 无法添加新回复