自定义组件在引入的父级选中不了
onReady: function () {//获得组件var redpocket = this.selectComponent("#redpocket") console.log(redpocket)}, |
页面中已经引入,是这样的:
<red-pocket id='redpocket' title='我是标题' content='恭喜你,学会了小程序组件' cancelText='知道了' confirm='谢谢你' isShow="{{isShow}}" bind:cancelEvent="_cancelEvent" bind:confirmEvent="_confirmEvent"> </red-pocket> |
然后我自己试了下,在OnReady中setTimeout。500ms之后可以选中这个元素
onReady: function () { //获得组件 setTimeout(function() { var redpocket = this.selectComponent("#redpocket") console.log(redpocket) //这里就可以取到这个组件 }.bind(this), 500) }, |
不知道是我写法问题吗,还是有bug,求指教!先谢过了
