- radio-group文档中关于事件参数的表述是否有歧义?
[图片] typeof(e.detail.value) => 'string' Array.isArray(e.detail.value) => false value 不是一个Array。但是按照文档中的表述,会让开发者试图保存e.detail.value[0]用于后续操作,实际上只有value字串的第一个字符,会造成错误。这里的表述应该修改一下,对初学者太不友好了。
2021-03-26 - 关于picker-view的value的问题
通过value指定了索引数组,但是显示出来的picker-view中的值往往是[0]或者[2],而非onLoad中setData的值。
2018-05-20 - textarea,失焦,找不到confirm事件处理方法之类的一堆问题
textarea的问题让人想骂娘,代码中的注释部分反映了大头处理这些问题的尝试,有些有用,有些没用。最后总地来说还是没用,从昨天晚上折腾到今天早上。 css类fxa-top的persition是fixed,所以一开始textarea的fixed = 'true'。这个时候输入一个字符键盘会消失,然后又会回来。这时page中有storePlan方法,该方法中的setData工作正常,但是app.store()没用(写在app里的方法,代替wx.setStorageSyn()在其它地方表现良好,有全局变量 var app = getApp())。错误提示:cannot read property data of undefined。这是我目前遇到的最好结果。 然后为了解决这个问题,大头开始想办法。先是把textarea放在了一个没有fixed的区域,去掉了fixed属性。结果一字失焦问题来了。失去焦点后由于触发blur事件,这一块儿就消失了。去掉bindinput这个问题消失,但是计数器就没了。 把storePlan由page的方法改成renewDsc的局部函数。现在触发textarea的confirm事件时,显示如下错误信息: property is not defined;at pages/detail page renewDsc function 已经饿得不行了,代码格式肯定是没问题的,其它的问题找不动了,大侠们快来帮帮我。我去吃饱了回来看。[代码]<!--view class="fxa-top" style='width:100%' wx:if="{{inputDsc}}"-->[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"weui-cells weui-cells_after-title "[代码] [代码]wx:if[代码][代码]=[代码][代码]"{{inputDsc}}"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"weui-cell"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"weui-cell__bd"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]textarea[代码] [代码]class[代码][代码]=[代码][代码]"weui-textarea"[代码] [代码]auto-focus[代码][代码]=[代码][代码]'true'[代码] [代码]placeholder[代码][代码]=[代码][代码]"描述"[代码] [代码]style[代码][代码]=[代码][代码]"height: 8em"[代码] [代码]maxlength[代码][代码]=[代码][代码]'200'[代码] [代码]name[代码][代码]=[代码][代码]'description'[代码] [代码]value[代码] [代码]= [代码][代码]"{{description}}"[代码] bindinput="countWords" [代码]bindblur[代码][代码]=[代码][代码]'description'[代码] [代码]bindconfirm[代码][代码]=[代码][代码]'renewDsc'[代码] [代码]/>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"weui-textarea-counter"[代码][代码]>{{counter}}/200</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]<!--/view-->[代码] [代码]data: {[代码][代码] [代码][代码]counter: 0,[代码][代码]},[代码][代码]/*storePlan: function () {[代码][代码] [代码][代码]var plan = {}, plans = this.data.plans, index = this.data.index;[代码][代码] [代码][代码]var p = this.data.plans[index];[代码][代码] [代码][代码]//delete p.detail;[代码][代码] [代码][代码]for (property in p) {[代码][代码] [代码][代码]plan[property] = this.data[property];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]plans[index] = plan;[代码][代码] [代码][代码]this.setData({[代码][代码] [代码][代码]plans: plans[代码][代码] [代码][代码]});[代码][代码] [代码][代码]app.store('plans', plans)[代码][代码]},[代码][代码]/**[代码][代码] [代码][代码]* 事件处理函数,监听textarea的blur和view的tap[代码][代码] [代码][代码]*/[代码][代码]description: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]var[代码] [代码]input = ![代码][代码]this[代码][代码].data.inputDsc;[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]inputDsc: input,[代码][代码] [代码][代码]})[代码][代码]},[代码][代码]/**[代码][代码] [代码][代码]* 事件处理函数,监听文本域输入事件,统计输入字数。[代码][代码] [代码][代码]*/[代码][代码]countwords: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]counter: e.detail.value.length[代码][代码] [代码][代码]})[代码][代码]},[代码][代码]/**[代码][代码] [代码][代码]* 监听理由文本域点击【完成】事件[代码][代码] [代码][代码]*/[代码][代码]renewDsc: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]description = e.detail.value;[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]//this.storePlan();[代码][代码] [代码][代码]storePlan();[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]description: description,[代码][代码] [代码][代码]inputDsc: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]});[代码][代码] [代码][代码]function[代码] [代码]storePlan(){[代码][代码] [代码][代码]var[代码] [代码]plan = {}, plans = that.data.plans, index = that.data.index;[代码][代码] [代码][代码]var[代码] [代码]p = that.data.plans[index];[代码][代码] [代码][代码]delete[代码] [代码]p.detail;[代码][代码] [代码][代码]for[代码] [代码](property [代码][代码]in[代码] [代码]p) {[代码][代码] [代码][代码]plan[property] = that.data[property];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]plans[index] = plan;[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]plans: plans[代码][代码] [代码][代码]});[代码][代码] [代码][代码]app.store([代码][代码]'plans'[代码][代码], plans)[代码][代码] [代码][代码]}[代码][代码]},[代码]
2018-02-12 - 表单submit时已经获取到了复选组的value,却提示can't read?
已经搞不清楚问题出在函数的哪个部分了,头大了好几圈啊……, [代码]<[代码][代码]form[代码] [代码]bindsubmit[代码] [代码]= [代码][代码]"submit"[代码][代码]>[代码] [代码]<[代码][代码]checkbox-group[代码] [代码]name[代码] [代码]= [代码][代码]"havechecked"[代码] [代码]>[代码][代码] [代码][代码]<[代码][代码]label[代码] [代码]wx:for[代码][代码]=[代码][代码]"{{list}}"[代码] [代码]wx:key[代码][代码]=[代码][代码]"sn"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]checkbox[代码] [代码]value[代码][代码]=[代码][代码]"{{index}}"[代码] [代码]checked[代码][代码]=[代码][代码]"{{item.checked}}"[代码] [代码]/>[代码][代码] [代码][代码]{{list.text}}[代码][代码] [代码][代码][代码]label[代码][代码]>[代码][代码][代码][代码] [代码][代码][代码]checkbox-group[代码][代码]>[代码][代码][代码][代码][代码][代码][代码]form[代码][代码]>[代码][代码][代码][代码] [代码]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
2018-02-08