猿问

小程序提示组件缺少method to handle event,为什么会这样?

method命名都检查都正确,死活提示缺少method。

这是报错:

Component "pages/classic" does not have a method "onPrevious" to handle event "right".
//这里是子组件中的methods 和 wxml

  methods: {
    onNext: function (event) {      if (!this.properties.latest) {        this.triggerEvent('left', {}, {})
      }
    },

    onPrevious: function (event) {      if (!this.properties.first) {        this.triggerEvent('right', {}, {})
      }
    }
   }

---------------------------------------------
<view class="container">
  <image bind:tap="onNext" class="icon" src="{{latest?disLeftSrc:leftSrc}}"/>
  <text class="title">{{title}}</text>
  <image bind:tap="onPrevious" class="icon" src="{{first?disRightSrc:rightSrc}}"/>
</view>

这里是page中的结构
<navi-cmp bind:left="onNext" bind:right="onPrevious" title="{{classic.title}}" first="{{first}}" latest="{{latest}}" class="navi" />


繁华开满天机
浏览 16365回答 1
1回答

幕布斯6054654

行吧,原来page.js中的方法也应该写上相同的onNext方法
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答