微信小程序form表单中button按钮、input框样式修改

2021/10/6 17:11:02

本文主要是介绍微信小程序form表单中button按钮、input框样式修改,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

  <form catchsubmit="formSubmit" catchreset="formReset">
        <view class="weui-cell__bd" style="margin: 30rpx 0">
          <text class="label">学生姓名</text>
          <input class="weui-input" name="学生姓名" placeholder="请输入" placeholder-class="placelo"/>
        </view>
        <view class="weui-cell__bd" style="margin: 30rpx 0">
          <text class="label">性别</text>
          <picker bindchange="pickSex" value="{{ gender }}" class="sex" range="{{ columns }}">
                <view>
                    {{ columns[gender] == "" ? "请输入性别" : "" }}{{ columns[gender] }}
                </view>
            </picker>
        </view>
        <view class="weui-cell__bd" style="margin: 30rpx 0">
          <text class="label">就读学校</text>
          <input class="weui-input" name="" placeholder="请输入" placeholder-class="placelo"/>
        </view>
        <view class="weui-cell__bd" style="margin: 30rpx 0">
          <text class="label">年纪</text>
          <input class="weui-input" name="" placeholder="请输入" placeholder-class="placelo"/>
        </view>
        <view class="weui-cell__bd" style="margin: 30rpx 0">
          <text class="label">班级</text>
          <input class="weui-input" name="" placeholder="请输入" placeholder-class="placelo"/>
        </view>
        <view class="weui-cell__bd" style="margin: 30rpx 0">
          <text class="label">家长电话</text>
          <input class="weui-input" name="" placeholder="请输入" placeholder-class="placelo"/>
        </view>
        <view class="weui-cell__bd" style="margin: 30rpx 0">
          <text class="label">居住地址</text>
          <input class="weui-input" name="" placeholder="请输入" placeholder-class="placelo" />
        </view>
        <view class="btn-area">
          <button formType="submit" size="default" class="btn">提交</button>
        </view>
      </form>
.weui-cell__bd{
  display:flex;
  justify-content: flex-start;
  align-items: center;
  border-bottom: 2rpx solid #EEEEEE;
  padding: 30rpx 0;
}
.weui-cell__bd .label{
  white-space: nowrap;
  margin-right: 22rpx;
  text-align:left;
  width: 20%;
  font-size: 32rpx;
  font-family: SourceHanSansCN-Regular;
  color: #666666;
  padding-left: 40rpx;
}
.btn{
width: 90% !important;
height: 80rpx;
background: #EFAA13;
border-radius: 40rpx;
font-size: 32rpx;
font-family: SourceHanSansCN-Regular;
color: #FFFFFF;
display:flex;
justify-content: center;
align-items: center;
padding: 0;
}
.placelo{
font-size: 32rpx;
font-family: SourceHanSansCN-Regular;
color: #999999;
text-align:left;
}
.sex{
font-size: 32rpx;
font-family: SourceHanSansCN-Regular;
color: #999999;
}

js

// pages/education/perfectInformation/perfectInformation.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    columns: ["请选择", "男", "女"],
    gender: 0 || wx.getStorageSync("gender") * 1,
  },
  pickSex: function(e) {
    this.setData({
        gender: e.detail.value
    });
    // console.log("当前选择性别-sex", e.detail.value);
},
    onSubmit(values) {
      console.log('submit', values);
    },
})

1.注意:button上面一定要加个类再给它给样式,给button{}给样式是覆盖不了原有的样式的,另外,当type=“primary”、“info”、“warning”、"danger"时给背景颜色是不起作用的!
2.input框样式修改
(1)样式style控制placeholder-style=“color:#CDCDCD”
(2)类名控制placeholder-class=“placeho”
.placeho{color:red}



这篇关于微信小程序form表单中button按钮、input框样式修改的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程