微信小程序 常用属性笔记

因长期不进行weapp开发,基础属性做个记录。

获取屏幕大小

wx.getSystemInfoSync().windowWidth 

行属性

display:flex;
flex-direction:row;

列属性

display:flex;
flex-direction:column;

列居中

align-items:center;

行居中

justify-content:center;

水平两端显示

justify-content:space-between;

水平等比显示

flex-direction:space-bround;
flex:1;

文本下划线、删除线

text-decoration:underline; //下划线
text-decoration:line-through;//删除线

悬浮层位置控制

position:fixed;
bottom:0;//底部显示
top:0;//右边显示
left:0;//左边显示
right:0;//右边显示

圆角显示

border-top-left-radius:7px;//左上角圆角
border-top-right-radius:7px;//右上角圆角
......

动态class或者style判断(单引号、双引号使用)

wxss
.text-nor{}
.text-pre{}
wxml
<text class="{{id==1?'text-pre':'text-nor'}}"></text>

保持手机不锁屏

wx.setKeepScreenOn({
  keepScreenOn:true,
})

本地json

//新建json.js文件
var localJson = [
    {"id":1,
    "name":'zhangsan'},
    {"id":2,
    "name":'lisi'}
]
moudle.exports={
postList:localJson}

//js页面读取
var postJson=require("../../jsondata/json.js");
var jsonList = postJson.postList;
Page({
    data:{
        list:jsonList   
    },
    itemClick:funciton(e){
        var id = e.currentTarget.dataset.id;
        wx.showToast(
            'title':id
        )
    }
})

列表页面

<view wx:for="{{list}}" wx:for-item="item" wx:for-index="index" wx:key="this">
    <text data-id="{{item.id}}" bindtap="itemClick">{{item.name}}</text>
</view>

圆圈背景的消息数量通知
消息通知文本背景

<view class='text-msg-bg center-x-y'>
  <text class='text-msg center-x-y'>1</text>
</view>


.text-msg-bg {
  width: 24px;
  height: 24px;
  background: red;
  border-radius: 50%;
}

.center-x-y {
  display: flex;
  justify-content: center;
  align-items: center;
}

.text-msg {
  color: white;
  font-size: 14px;
  padding: 2px;
}

比较好用的图表(感谢作者分享)
如:饼状图、环状图、条形图、折线图等
https://blog.csdn.net/m0_37805167/article/details/75160063

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值