wepy定义组件,绑定事件bindchange出现事件警告
本人想要把swiper封装成组件,需要重写点dot点样式,所以关闭了官方的indicatorDots: false,自行绑定bindchange事件,希望在图片变换的时候能够改变自己的dot的样式 [代码]<[代码][代码]template[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]swiper[代码] [代码]indicator-dots[代码][代码]=[代码][代码]"{{indicatorDots}}"[代码][代码] [代码][代码]autoplay[代码][代码]=[代码][代码]"{{autoplay}}"[代码] [代码]interval[代码][代码]=[代码][代码]"{{interval}}"[代码] [代码]duration[代码][代码]=[代码][代码]"{{duration}}"[代码][代码] [代码][代码]bindchange[代码][代码]=[代码][代码]"toChange"[代码][代码] [代码][代码]class[代码][代码]=[代码][代码]"swiper"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:for[代码][代码]=[代码][代码]"{{imgUrls}}"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]swiper-item[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]src[代码][代码]=[代码][代码]"{{item}}"[代码] [代码]class[代码][代码]=[代码][代码]"slide-image"[代码] [代码]style[代码][代码]=[代码][代码]"width:100%;height:100%;"[代码][代码]/>[代码][代码] [代码][代码]</[代码][代码]swiper-item[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]swiper[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"dots"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]block[代码] [代码]wx:for[代码][代码]=[代码][代码]"{{imgUrls}}"[代码] [代码]wx:key[代码][代码]=[代码][代码]"unique"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"dot {{index === swiperCurrent?'active':''}}"[代码][代码]></[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]block[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码]</[代码][代码]template[代码][代码]>[代码][代码]<[代码][代码]script[代码][代码]>[代码][代码] [代码][代码]import wepy from 'wepy'[代码] [代码] [代码][代码]export default class Slider extends wepy.component {[代码][代码] [代码][代码]props = {[代码][代码] [代码][代码]imgUrls: {[代码][代码] [代码][代码]type: Array,[代码][代码] [代码][代码]default: [][代码][代码] [代码][代码]},[代码][代码] [代码][代码]indicatorDots: {[代码][代码] [代码][代码]type: Boolean,[代码][代码] [代码][代码]default: false[代码][代码] [代码][代码]}[代码][代码] [代码][代码]};[代码][代码] [代码][代码]data = {[代码][代码] [代码][代码]autoplay: true,[代码][代码] [代码][代码]interval: 5000,[代码][代码] [代码][代码]circular: true,[代码][代码] [代码][代码]duration: 1000,[代码][代码] [代码][代码]swiperCurrent: 0[代码][代码] [代码][代码]};[代码][代码] [代码][代码]toChange(e) {[代码][代码] [代码][代码]console.log('swiperChange');[代码][代码] [代码][代码]this.swiperCurrent = e.detail.current;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}[代码]但是微信开发者工具调用toChange的时候报了一下错误,导致无法使用 Do not have $slider$toChange handler in current page: pages/home. Please make sure that $slider$toChange handler has been defined in pages/home, or pages/home has been added into app.json [图片] 但是如果是直接写在page,就是extends wepy.page的页面是没有问题。有什么办法能让组件能自己管理这个事件吗