关于uni-app 在弹出Popup时让input自动获取焦点的问题

 

关于uni-app 在弹出Popup时让input自动获取焦点的问题

分类:uni-app

input popup uniapp

在微信小程序的时候有时正常弹出,有时不弹出,有时弹出后input与软键盘中间有一大块空白区域,不知道哪里出了问题,各位大佬给看看,小弟谢过!
代码片段:

复制代码<template>  
    <view>  
        <view class="bottomWrapper">  
            <view>  
                <view class="buttonWrapper" @click="commentClick">  
                    <uniIcon type='chat' color="#333" size="24"></uniIcon>  
                    <view>评论</view>  
                </view>  
            </view>  
        </view>  
        <uni-popup ref="popup" type="bottom" :change='handelChange'>  
            <view class="publishWrapper">  
                <input type="text" confirm-type='done' v-model="myText" placeholder='说点什么吧' :focus='setFocus' cursor-spacing='15px' />  
                <view :style="{color:publishColor}">发布</view>  
            </view>  

        </uni-popup>  
    </view>  
</template>

数据:

复制代码    import uniIcon from "@dcloudio/uni-ui/lib/uni-icon/uni-icon"  
    import uniPopup from "@dcloudio/uni-ui/lib/uni-popup/uni-popup"  
    export default {  
        data() {  
            return {  
                myText:'',  
                setFocus:false  
            };  
        },  
        computed:{  
            publishColor(){  
                if(this.myText){  
                    return '#ff4049'  
                }else{  
                    return '#999'  
                }  
            }  
        },  
        components:{uniIcon, uniPopup},  
        methods:{  
            commentClick(){  
                this.$refs.popup.open()  
                this.setFocus=true  
            },  
            handelChange(){  

            }  
        }  
    }

css样式:

复制代码    .bottomWrapper{  
    position: fixed;  
    bottom: 0;  
    background-color: #fff;  
    width: 100%;  
    padding: 16rpx 10rpx;  
    border-top: 1px solid $uni-border-color;  
}  
.buttonWrapper{  
    text-align: center;  
    display: flex;  
    justify-content:center;  
    align-items:center;  
    font-size: $uni-font-size-base;  
    color: $uni-text-color;  
}  
.publishWrapper{  
    display: flex;  
    // padding: 6rpx;  
    justify-content: space-between;  
    input{  
        border: 1px solid $uni-border-color;  
        border-radius: 40rpx;  
        padding-left: 20rpx;  
        width: 70%;  
    }  
    view{  
        width: 20%;  
        text-align: center;  
    }  
}

部分截图:

 

 

 

 

 

 

 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值