小程序
小游戏
企业微信
微信支付
扫描小程序码分享
通过fixed定位输入框做回复功能,输入完成点击“完成”按钮后 ,输入框又自动focus调出键盘,是什么原因
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
组件代码
//点击评论按钮
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') {
url: API + '/moment/detail',
momentId: momentId
var detail = res.data.data
for (var i in basicList) {
if(detail.momentId === basicList[i].momentId) {
basicList[i].commentList = detail.commentList
}
list: basicList
console.log(that.data)
} else {
common.returnCodeCheck(res.data.returnCode, that.sendComment)
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>
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
组件代码
//点击评论按钮
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>
麻烦给个相关的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html),我们定位下问题