通过fixed定位输入框做回复功能,输入完成点击“完成”按钮后 ,输入框又自动focus调出键盘,是什么原因
组件代码
//点击评论按钮
comment: function (e) {
console.log(e)
var pageY = e.changedTouches[0].pageY
var id = e.currentTarget.dataset.id
this.setData({
showOpetationBtn: false,
momentId: id,
pageY: pageY,
showCommentInput: true,
commentInputFocus: true
})
},
//发送评论
sendComment: function (e) {
var that = this
var header = common.getHeader()
var commentText = e.detail.value
var momentId = this.data.momentId
var basicList = this.data.list
that.setData({
showCommentInput: false,
commentInputFocus: false
})
wx.request({
url: API + ‘/comment/add’,
method: ‘POST’,
data: {
token: header.TOKEN,
momentId: momentId,
commentContent: commentText
},
success: res => {
if (res.data.returnCode === ‘00000’) {
wx.request({
url: API + ‘/moment/detail’,
method: ‘POST’,
data: {
token: header.TOKEN,
momentId: momentId
},
success: res => {
if (res.data.returnCode === ‘00000’) {
var detail = res.data.data
for (var i in basicList) {
if(detail.momentId === basicList[i].momentId) {
basicList[i].commentList = detail.commentList
}
}
that.setData({
list: basicList
})
console.log(that.data)
} else {
common.returnCodeCheck(res.data.returnCode, that.sendComment)
}
}
})
} else {
}
}
})
page代码
<view class=“comment-input-container” wx:if="{{showCommentInput}}">
<input class=“comment-input” type=“text” focus="{{commentInputFocus}}" bindinput=“getComment” bindconfirm=“sendComment” cursor-spacing=“10”></input>
</view>