zoukankan      html  css  js  c++  java
  • 小程序中点击input控件键盘弹出时placeholder文字上移

      最近做的一个小程序项目中,出现了点击input控件键盘弹出时placeholder文字上移,刚开始以为是软键盘弹出布局上移问题是传说中典型的fixed 软键盘顶起问题,因此采纳了网上搜到的“当获取焦点时,将fixed的元素改为static;失去焦点,再改回fixed”的方法,然而行不通,我试着给input加了个边框,然而当软键盘弹出时input框并没有移动,仅仅是input中的placeholder上移了,因此只能想到了让placeholder文字在聚焦是为空,在失焦是显示为指定值一下为具体代码

    xml
    <input id='searchInput' placeholder='{{phValue}}' type="text"  bindfocus='onFocus' bindblur='onBlur'/>
     
    js
    Page({
    // 页面的初始数据
    data: {
    phValue:"请输入要录入的单词"
    },
    onFocus: function (e) {
    this.setData({
    phValue:" "
    })
    },
    onBlur: function (e) {
    this.setData({
    phValue: "请输入要录入的单词"
    })
    }
    })


  • 相关阅读:
    OI省选知识清单
    FWT板子
    [APIO2018]选圆圈
    [APIO2018]铁人两项
    [Test-1.11]-T4 Transform
    [Test-1.11]-T2divisor
    [Test1.11]-T3对合
    [Test3.3]-T3 Sorting (卡常)
    [Test1.11]-T1匹配 Matching
    二、Unity调用Xcode封装方法
  • 原文地址:https://www.cnblogs.com/joyer-lee/p/8117599.html
Copyright © 2011-2022 走看看