onDelete组建内部事件不触发
来源:14-11 搜索实现3

慕函数2572657
2019-06-14
<!--components/search/index.wxml-->
<view class="container">
<view class="header">
<view class="search-container">
<image class="icon" src="images/search.png" />
<input value="{{word}}" bind:confirm="onConfirm" placeholder-class='in-bar' placeholder='书籍名' class='bar' auto-focus="true" />
<image bind:tap="onDelete" class="cancel-img" src="images/cancel.png" />
</view>
<view bind:tap="onCancel" class='cancel'>取消</view>
</view>
<view wx:if="{{!searching}}">
<view class="history">
<view class="title">
<view class="chunk"></view>
<text>历史搜索</text>
</view>
<view class="tags">
<block wx:key="" wx:for="{{historyWords}}">
<r-tag bind:tapping="onConfirm" text="{{item}}" />
</block>
</view>
</view>
<view class="history hot-search">
<view class="title">
<view class="chunk"></view>
<text>热门搜索</text>
</view>
<view class="tags">
<block wx:key="" wx:for="{{hotWords}}">
<r-tag bind:tapping="onConfirm" text="{{item}}" />
</block>
</view>
</view>
</view>
<view wx:if="{{searching}}" class="books-container">
<block wx:for="{{dataArray}}" wx:key="{{item.id}}">
<r-book showLike="{{false}}" book="{{item}}" class="book" />
</block>
</view>
</view>
// components/search/index.js
Component({
properties: {
historyWords: Object,
hotWords: Object,
dataArray: Object,
},
data: {
searching: false,
word:""
},
lifetimes: {
attached: function() {
}
},
methods: {
onCancel(event) {
this.triggerEvent('cancel', {}, {});
},
onDelete(event) {
this.setData({
searching: false
})
},
onConfirm(event) {
const word = event.detail.value||event.detail.text;
this.setData({
searching: true,
word
})
this.triggerEvent('confirm', {
word: word
}, {});
}
}
})
求助!!!
写回答
3回答
-
ZGDbb
2019-07-02
这个原因 我试了一下 好像不支持在image上绑定事件, 我在外层嵌套了一层view就可以了
10 -
慕移动7441361
2019-10-21
我告诉你为什么,你把按钮调大一点再试试,我也很无奈
00 -
慕九州3352676
2019-10-14
我也添加了为什么还是不行
00
相似问题