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) }, |
组件ID是不是重复了啊
你好,请提供一下能复现问题的简单代码片段,ec-canvas使用canvas替代即可(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。