onReady中,用selectComponent取wx:for下组件为null
onReady中,用selectComponent取wx:for下包含的组件,取不到。 如果把该组件移到wx:for之外,是可以取到的。 [代码]<view [代码][代码]class[代码][代码]=[代码][代码]"articles"[代码][代码]>[代码][代码] [代码][代码]<view wx:[代码][代码]for[代码][代码]=[代码][代码]"{{articles}}"[代码] [代码]class[代码][代码]=[代码][代码]"article"[代码] [代码]wx:[代码][代码]for[代码][代码]-index=[代码][代码]"idx"[代码] [代码]data-aid=[代码][代码]"{{item.article_id}}"[代码] [代码]bindtap=[代码][代码]"onArticleClicked"[代码][代码]>[代码][代码] [代码][代码]<view [代码][代码]class[代码][代码]=[代码][代码]"container"[代码][代码]>[代码][代码] [代码][代码]<ec-canvas id=[代码][代码]"mychart_0"[代码] [代码]canvas-id=[代码][代码]"mychart-bar"[代码] [代码]ec=[代码][代码]"{{ ec }}"[代码][代码]></ec-canvas>[代码][代码] [代码][代码]</view>[代码][代码] [代码][代码]</view>[代码][代码]</view>[代码] [代码]onReady() {[代码][代码] [代码][代码]//获取组件[代码][代码] [代码][代码]this[代码][代码].ecComponent = [代码][代码]this[代码][代码].selectComponent([代码][代码]'#mychart_0'[代码][代码]);[代码][代码] [代码][代码]console.log([代码][代码]'============================='[代码][代码])[代码][代码] [代码][代码]console.log([代码][代码]this[代码][代码].ecComponent)[代码][代码]},[代码]