微信小程序单元格嵌入复选框问题
wtml
<van-checkbox-group value="{{result}}" bind:change="onChangeList">
<van-cell-group>
<van-cell
wx:for="{{zhuisuall}}"
wx:key="index"
title="{{item.time}}"
label="{{item.code}}"
value-class="value-class"
clickable
data-index="{{index}}"
title-width="94%"
bind:click="toggle"
center
>
<van-checkbox name="{{item.code}}" data-data="{{item}}"></van-checkbox>
</van-cell>
</van-cell-group>
</van-checkbox-group>
js错误部分
toggle(event) {
const { index } = event.currentTarget.dataset;
const checkbox = this.selectComponent('.checkboxes-${index}');//报错位置
console.log(checkbox)
checkbox.toggle();//报错位置
},
控制台显示
WAServiceMainContext.js?t=wechat&s=1702943822673&v=3.1.0:1 TypeError: Cannot read property 'toggle' of null
at pi.toggle (VM2198 a.js:47)
at pi.<anonymous> (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)
at o.safeCallback (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)
at o.call (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)
at r (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)
at WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1
at l (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)
at Function.o.dispatchEvent (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)
at Function.o.triggerEvent (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)
at l.d.triggerEvent (WASubContext.js?t=wechat&s=1702943822673&v=3.1.0:1)(env: Windows,mp,1.06.2301160; lib: 3.1.0)