React Native 购物车数量红色小角标封装
来源:互联网 发布:双十一成交额实时数据 编辑:程序博客网 时间:2024/06/11 09:53
import React, {Component} from 'react';import { StyleSheet, View, Dimensions, Text} from 'react-native';const {width, height} = Dimensions.get('window');//模块声名并导出export default class CountTag extends Component { //属性声名 static propTypes = { text: React.PropTypes.any }; //默认属性 static defaultProps = { fontSize: Constant.fontSizeXSmall,//字体大小 backgroundColor: Constant.colorTxtPrimary,//背景颜色 color: '#ffffff',//字体颜色 defaultWidth: 14, }; //构造函数 constructor(props) { super(props); this.state = { //状态机变量声明 } } //渲染 render() { return ( <View style={[styles.contentStyle,this.props.style,{backgroundColor: this.props.backgroundColor,borderColor: this.props.backgroundColor,minWidth: this.props.defaultWidth,height: this.props.defaultWidth}]}> <Text numberOfLines={1} style={{color: this.props.color,fontSize:this.props.fontSize,margin:3}}>{this.props.text}</Text> </View> ); }};const styles = StyleSheet.create({ contentStyle: { borderRadius: 100, position: 'absolute', alignItems: 'center', justifyContent: 'center', flexDirection: 'row', }});
使用
<CountTag style={{}} text={0 < this.state.count < 100 ? this.state.count : "99+" }/> // text为any类型,可以数字,可以字符串
阅读全文
0 0
- React Native 购物车数量红色小角标封装
- React Native 利用自定义button封装购物车计数器
- react native封装UI
- react native Toast封装
- react-native http封装
- react-native modal封装
- React Native 控件封装
- React Native TableViewCell封装
- React-Native Demo 购物app
- react native基于redux架构实现登陆和购物车
- 一起学react native(4) Mobx实现简单购物车
- 一起学react native实现简单购物车
- react native基于redux架构实现登陆和购物车
- React Native实战系列第十四篇——购物车
- react-native 仿京东加入购物车动画效果
- react-native 仿京东加入购物车动画效果
- 购物车数量提醒
- 购物车数量加减
- OnUiCallback
- 对海康28181摄像头PS流解码的支持(三)
- 深入理解ES6箭头函数的this以及各类this面试题总结
- 文章标题
- Mybatis中trim标签的使用
- React Native 购物车数量红色小角标封装
- 回溯法(2)
- 开始学习linux,U盘安装linux的centos7出现错误,进入不到安装界面,最后解决办法
- android开发之如何知晓App是否已签名
- P1508 Likecloud-吃、吃、吃
- 通过模块参数进程PID打印进程的虚存区
- Oracle的多表连接方式
- TabLayout使用
- 第九周【项目2