uniapp使用输入框固定在底部键盘弹起把输入框挡住问题

 给input输入框设置cursor-spacing这属性就好

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
实现这个功能需要用到uniapp的组件和事件。 首先,在页面中添加一个textarea组件,用于用户输入评论内容: ``` <template> <view> <textarea class="comment-input" v-model="comment" placeholder="请输入评论内容" @focus="showInputBox" ></textarea> </view> <view :class="['input-box', {show: showBox}]"> <textarea class="input-textarea" v-model="comment" placeholder="请输入评论内容" @blur="hideInputBox" ></textarea> </view> </template> ``` 在组件中,使用v-model绑定comment变量,用于存储用户输入的评论内容。同时,在textarea的focus事件中调用showInputBox方法,显示底部输入框。 ``` <script> export default { data() { return { comment: '', showBox: false } }, methods: { showInputBox() { this.showBox = true }, hideInputBox() { this.showBox = false } } } </script> ``` 在showInputBox方法中,将showBox变量设置为true,用于显示底部输入框。在hideInputBox方法中,将showBox变量设置为false,用于隐藏底部输入框。 最后,在底部输入框中也添加一个textarea组件,并在blur事件中调用hideInputBox方法,用于隐藏输入框。 同时,需要添加CSS样式,用于控制底部输入框的显示和隐藏: ``` <style> .comment-input { height: 100px; border: none; outline: none; resize: none; font-size: 28rpx; padding: 20rpx; } .input-box { position: fixed; bottom: 0; left: 0; right: 0; height: 200rpx; background-color: #fff; transform: translateY(200rpx); transition: transform 0.3s ease-in-out; } .input-box.show { transform: translateY(0); } .input-textarea { height: 160rpx; border: none; outline: none; resize: none; font-size: 28rpx; padding: 20rpx; } </style> ``` 这样,就实现了仿照小红书评论界面的功能,点击输入框时,底部弹出输入框键盘

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值