uniapp里的 radio-group组件change时候需要获取index

  • Post author:
  • Post category:uniapp


<label class=”listItem” v-for=”(item, index) in submitData.targetOptions” :key=”index”>

<radio class=”radioSel” :value=”index+”” :checked=”index === current” />

<view class=”radioTxt”>{

{item.targetOptionName}}</view>

</label>

组件只能获取到value,value是个字符串类型,直接写index会报错

Invalid prop: type check failed for prop “value”. Expected String with value “0”, got Number with value 0

需要将index转换成字符串

方法是 index+‘’



版权声明:本文为beifanggongy原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。