zoukankan      html  css  js  c++  java
  • 小程序uni-app处理input框将页面往上推动的解决办法

    1. view

    <view class="bottom-wri-box" :style="{bottom: bottomHeight}">
    	<image @tap="changeChander" class="left-cont-icon" :src="imageUrl+'/huifu-icon.png'"></image>
    	<input  
    	:adjust-position="flasFlag"
    	@confirm="AddSendMess"
    	class="mormal-input uni-input"
    	maxlength="300"
    	@focus="getheightCont"
    	@blur="initheight"
    	confirm-type="send"
    	placeholder="说点什么" 
    	v-model="writeCont" />
    </view>
    

    2. data中的值,用于控制input输入框的位置;

    flasFlag:false, //表示input输入时,页面不会往上推动
    bottomHeight:'0rpx',//input框的数据
    
    

    3.mthods中的方法动态控制input框中的位置

    methods:{
      getheightCont(e){
        //e.detail.height 用户获取键盘的高度,由于机型的不同,所以可以加上一个值10或者20
        this.bottomHeight=(e.detail.height*2)+10+"rpx";//你可以加上20或者加上10
      },
      initheight(){ 
         this.bottomHeight='0rpx'
      },
    }
    
    

    4.css

    .bottom-wri-box{
       100%;
       background-color:#fff;
       position:fixed !important; //一定要固定定位哈
    		
       height: 152rpx;
       display: flex;
       align-items: center;
       justify-content: center;
       z-index: 1000 !important;
       box-shadow: 0px -2px 20px 0px rgba(0,0,0,0.05); 
       .mormal-input{
           604rpx;
          height: 80rpx;
          background: #f5f5f5;
          border-radius: 44rpx;
          padding-left: 34rpx;
          box-sizing: border-box;
          padding-right: 32rpx;
           //注意input框中内容太多可能会出现样式移溢出
          white-space:normal !important; 
          word-break:break-all !important; 
    
          margin-left:28rpx;
    }
      // 左侧图标 右侧表情
      .left-cont-icon{
            54rpx;
           height: 54rpx;
       }
    }
    
    我们在输入的时候,发现页面并没有往上推动;
    这样我们就完美的解决了input框将页面往上推动的机制;
    

    作者:流年少年
    出处:https://www.cnblogs.com/ishoulgodo/

    想问问题,打赏了卑微的博主,求求你备注一下的扣扣或者微信;这样我好联系你;(っ•̀ω•́)っ✎⁾⁾!

    如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,或者关注博主,在此感谢!

    万水千山总是情,打赏5毛买辣条行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主(っ•̀ω•́)っ✎⁾⁾!

    想问问题,打赏了卑微的博主,求求你备注一下的扣扣或者微信;这样我好联系你;(っ•̀ω•́)っ✎⁾⁾!

    支付宝
    微信
    本文版权归作者所有,欢迎转载,未经作者同意须保留此段声明,在文章页面明显位置给出原文连接
    如果文中有什么错误,欢迎指出。以免更多的人被误导。
  • 相关阅读:
    第一课 GCC入门
    第二课客户端链接Linux系统
    2014目标!!!!
    第一课Linux系统安装知识(2)
    android开发系列之ContentObserver
    android开发系列之数据存储
    android开发系列之视频断点续传
    稻盛和夫系列之活法一
    android开发系列之使用xml自定义控件
    android开发系列之MVP设计模式
  • 原文地址:https://www.cnblogs.com/ishoulgodo/p/14650707.html
Copyright © 2011-2022 走看看