表单submit时已经获取到了复选组的value,却提示can't read?
已经搞不清楚问题出在函数的哪个部分了,头大了好几圈啊……,
< checkbox-group name = "havechecked" > < label wx:for = "{{list}}" wx:key = "sn" > < checkbox value = "{{index}}" checked = "{{item.checked}}" /> {{list.text}}
|
data: { list:[...] } submit: function (){ var list = this .data.list; var value = e.detail.value; var toDelete = value.havechecked; console.log(toDelete, value); toDelete.forEach( function (v) { list.splice[v, 1]; }); for ( var i = 0; i < list.length; ++i) { list[i].checked = false ; } this .setData({ list: list, }) }, |
结果:
[“1”,“2”,“0” ] {havechecked: Array(3)}
Cannot read property ‘havechecked’ of undefined;at /…/… submit function
TypeError: Cannot read property ‘havechecked’ of undefined