美文网首页
【uniapp】小程序中input输入框的placeholder

【uniapp】小程序中input输入框的placeholder

作者: 王哈哈zzz | 来源:发表于2022-10-27 14:25 被阅读0次

一、问题描述:

  • input框中的placeholder属性是可以更改样式,更改的方式为placeholder-class="你的style名"

example:

<view class="top_one">
      <text>姓名</text> 
      <input type="text" placeholder="请输入姓名" placeholder-class="placeholder_class"/> //(注释)这里---- placeholder_text
</view>
<view class="top_two">
    <text>手机号码</text><input type="number" placeholder="手机号" />
</view>
<style>
     .placeholder_class {
        font-family: 'Source Han Sans CN';
        font-weight: 350;
        font-size: 24rpx;
        color: #747474;
     }
</style>

二、解决办法:

  • 但是这个属性如果使用了<style scoped>就不生效,所以我们可以单独再写一个style:
<style>
    .placeholder-class {
        color: #BFBFBF;
    }
</style>
<style scoped lang="scss">
    .placeholder-class {
        color: #BFBFBF;
    }
</style>

相关文章

网友评论

      本文标题:【uniapp】小程序中input输入框的placeholder

      本文链接:https://www.haomeiwen.com/subject/vrqftdtx.html