<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>
6***@qq.com
正解,感谢!
2022-01-03 10:37