想在主页上添加一个搜索功能 但是加上之后发现原有的页面点击事件没有反应了 个人怀疑是input和bindtap互相影响?
有人碰到类似的情况吗 是怎么解决的
<input class="textinput" bindinput="bindinput" value="{{inputValue}}" placeholder="请输入内容" />
</view>
<scroll-view scroll-y="true" class="scrollview">
<view wx:for="{{bindSource}}">
<view class="block1">
<view id="{{item}}" bindtap="itemtap" class="itemview">{{item}}</view>
</view>
</view>
</scroll-view>
<view >
<text>this is a text</text>
<view class="block" bindtap="artsblock">
<view>
<text class="fontstyle" >LECTURE THEATRES</text>
</view>
</view>
``
Page({
data: {
inputValue: '',//点击结果项之后替换到文本框的值
adapterSource: ["123", "321", "666", "weixin", "WeiXin", "wechat", "android", "Android", "ios", "iOS", "java", "javascript", "微信小程序", "微信公众号", "微信开发者",
"微信开发者工具"],//本地匹配源
bindSource: [],//绑定到页面的数据,根据用户输入动态变化
actionSheetHidden: true,
},
onLoad: function () {
//这里可以写请求网络数据的代码,请求服务器的匹配源
},
actionSheetTap: function () {
this.setData({
actionSheetHidden: !this.data.actionSheetHidden
})
},
actionSheetbindchange: function () {
this.setData({
actionSheetHidden: !this.data.actionSheetHidden
})
},
//当键盘输入时,触发input事件
bindinput: function (e) {
var prefix = e.detail.value//用户实时输入值
var newSource = []//匹配的结果
if (prefix != "") {
this.data.adapterSource.forEach(function (e) {
if (e.indexOf(prefix) != -1) {
newSource.push(e)
}
})
}
if (newSource.length != 0) {
this.setData({
bindSource: newSource
})
} else {
this.setData({
bindSource: []
})
}
},
itemtap: function (e) {
this.setData({
inputValue: e.target.id,
bindSource: []
})
},
artsblock: function () {
wx.navigateTo({
url: "../lectureTheatres/lectureTheatres",
})
},
})
点击事件没触发一般有两种情况,一是事件没绑定对,二是点击事件没在绑定的元素上触发,比如层级的影响。