小程序开发笔记

1,map等原生组件层级是最高的,要想在上面覆盖其他元素,要用cover-text 或者 cover-view组件

2, 使用cover-view时要注意fixed定位问题,如果有滚动区域,例如新闻列表等,在下拉刷新或点击分页等行为加载新数据后,定位的cover-view可能会卡在之前的位置,就是不会固定在底部,暂时这个问题只出现苹果手机上。

解决方法:滚动的区域换成 scroll-view 组件 ,这样就可以解决这个问题。       参考链接:http://html51.com/info-53347-1/

3, 图片转base64的方法,用wx.chooseImage()方法选择图片后,得到 res.tempFilePaths 的本地路径 

let url = 'data:image/jpg;base64,'+wx.getFileSystemManager().readFileSync(res.tempFilePaths[0], "base64")   //用这个方法可以得到base64码

4, 微信有时请求不到后端接口

wx.request({
      url: 'https://h5.houjt.com/userproject/carlsberg/common/controllers/uf.php?command=3', 
      data: data,
      method:'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"     //要把头部的设置改改就行
      },
      success(res) {
        // console.log(res.data)
       
      }
    })

5,要想调起授权, 获取用户信息 ,必须要用 button open-type = getUserInfo 

6, 修改radio组件的样式

* radio未选中时样式 */ 

radio .wx-radio-input{ 
  /* 自定义样式.... */
    height: 40rpx; 
    width: 40rpx;
    margin-top: -4rpx;
    border-radius: 50%;
    border: 2rpx solid #999;
    background: transparent;
 }



/* 选中后的 背景样式 (红色背景 无边框 可根据UI需求自己修改) */
radio .wx-radio-input.wx-radio-input-checked{
   border: none;
   background: red;
}
/* 选中后的 对勾样式 (白色对勾 可根据UI需求自己修改) */
radio .wx-radio-input.wx-radio-input-checked::before{
   border-radius: 50%;/* 圆角 */
   width: 40rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
   height: 40rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
   line-height: 40rpx;
   text-align: center;
   font-size:30rpx; /* 对勾大小 30rpx */
   color:#fff; /* 对勾颜色 白色 */
   background: #f00;
   transform:translate(-50%, -50%) scale(1);
   -webkit-transform:translate(-50%, -50%) scale(1);
}
--------------------- 
作者:静默思想 
来源:CSDN 
原文:https://blog.csdn.net/weixin_41871290/article/details/82686719 
版权声明:本文为博主原创文章,转载请附上博文链接!

修改checkbox样式

/*checkbox 整体大小  */
checkbox {
  width: 240rpx;
  height: 90rpx;
}
/*checkbox 选项框大小  */
checkbox .wx-checkbox-input {
  width: 50rpx;
  height: 50rpx;
}
/*checkbox选中后样式  */
checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  background: #FF525C;
}
/*checkbox选中后图标样式  */
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
  width: 28rpx;
  height: 28rpx;
  line-height: 28rpx;
  text-align: center;
  font-size: 22rpx;
  color: #fff;
  background: transparent;
  transform: translate(-50%, -50%) scale(1);
  -webkit-transform: translate(-50%, -50%) scale(1);
}

7,阻止事件冒泡 绑定事件时将 bindtap 改成 catchtap 

原文地址:https://www.cnblogs.com/haqiao/p/10771250.html