Framework innererror(expect FLOW_MINIPULATE_CHILD but get another)

Uncaught error:expect END descriptor with depth 0 but get another

2019.3.19号晚上,很久没动的代码,线上忽然报这个错误。

经过排查,问题如下:

页面定义的data对象的变量 config:null

代码设置config的值,设置为数组 this.setData({config:[xxx,xxx]});

然后将config传递到子组件A,子组件A用properties接受,设置为Array

properties:{config:Array}

然后子组件A中含有子组件B,然后在子组件B的属性设置了wx:if="{{config}}"

以上情况手机运行直接报错。

修改方式有如下几种:

1、在子组件A上的子组件B,修改wx:if="{{config&&config.length}}"

2、在子组件A中,修改properties,

properties:{    config:[Array,null]}

3、修改页面定义的初始默认值,将config:null修改为config:[]

以上三种方法都能解决这个问题。显然,第三种才是最合理的做法。也就是定义的变量的类型和设置的数据类型和子组件接受的数据类型,三者保持一致。

TAG标签: 微信小程序uncaught

http://www.xiaochengxub.com/read-103397.html