为什么我的绑定事件没有在微信小程序中调用?

时间:2017-01-17 09:11:42

标签: wechat

这是我的代码:

search.wxml

<view class="search">
    <view class="section">
        <input id="input-word" placeholder="请输入您要查询的文本" focus/>
        <view id="cancel-button" bindTap="navigateBack" class="navigator" >取消</view>
    </view>
</view>

search.js

Page({
  onLoad: function () {
    console.log('onLoad-search')

  },

  // back
  navigateBack: function(e) {
    console.log("back");  // this do not log out, when I click my view
  }

})

1 个答案:

答案 0 :(得分:1)

函数“navigateBack”的位置是错误的。你应该这样说:

navigateBack: function(e) {
    console.log("back");  // this do not log out, when I click my view
}
onload: function() {
    console.log('onLoad-search')
}