微信小程序-button组件自定义样式

<button class='btn' bindtap='sumbit' >肯定</button>

(1)修改按钮颜色css

background-color:修改背景颜色,color:修改字体颜色字体

.btn{
   background-color:black;
   color:#ffff;
}

若是<button></button>里面定义 type='XX',就会默认button按钮的样式code

其中type有效值有三种:get

说明
primary 绿色
default 白色
warn 红色

(2)设置按钮点击时的颜色it

<button class='btn' bindtap='sumbit' hover-class="other-button-hover">肯定</button>

 定义css样式io

/** 修改button默认的点击态样式类**/
.button-hover {
  background-color: red;
}
/** 添加自定义button点击态样式类**/
.other-button-hover {
  background-color: blue;
}

 (3)获取用户信息console

getUserInfo 获取用户信息,能够从bindgetuserinfo回调中获取到用户信息
<button open-type="getUserInfo" lang="zh_CN" bindgetuserinfo="onGotUserInfo">获取用户信息</button>

在对应的js文件中:table

onGotUserInfo: function(e) {
    console.log(e.detail.errMsg)
    console.log(e.detail.userInfo)
    console.log(e.detail.rawData)
  },