| ¶Ô±ÈÐÂÎļþ |
| | |
| | | export default { |
| | | props: { |
| | | // flexæåæ¹å¼ |
| | | flexDirection: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // flex-directionçç®å |
| | | fd: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // å±ç¤ºç±»å |
| | | display: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // displayç®å |
| | | d: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // 主轴æåæ¹å¼ |
| | | justifyContent: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // justifyContentçç®å |
| | | jc: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // 纵轴æåæ¹å¼ |
| | | alignItems: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // align-itemsçç®å |
| | | ai: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | color: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // colorç®å |
| | | c: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // åä½å¤§å° |
| | | fontSize: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // font-sizeç®å |
| | | fs: { |
| | | type: [String, Number], |
| | | default: '' |
| | | }, |
| | | margin: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // marginç®å |
| | | m: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-top |
| | | marginTop: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-topç®å |
| | | mt: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-right |
| | | marginRight: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-rightç®å |
| | | mr: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-bottom |
| | | marginBottom: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-bottomç®å |
| | | mb: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-left |
| | | marginLeft: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // margin-leftç®å |
| | | ml: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-left |
| | | paddingLeft: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-leftç®å |
| | | pl: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-top |
| | | paddingTop: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-topç®å |
| | | pt: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-right |
| | | paddingRight: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-rightç®å |
| | | pr: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-bottom |
| | | paddingBottom: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // padding-bottomç®å |
| | | pb: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // border-radius |
| | | borderRadius: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // border-radiusç®å |
| | | radius: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | // transform |
| | | transform: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // å®ä½ |
| | | position: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // positionç®å |
| | | pos: { |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | // 宽度 |
| | | width: { |
| | | type: [String, Number], |
| | | default: null |
| | | }, |
| | | // widthç®å |
| | | w: { |
| | | type: [String, Number], |
| | | default: null |
| | | }, |
| | | // é«åº¦ |
| | | height: { |
| | | type: [String, Number], |
| | | default: null |
| | | }, |
| | | // heightç®å |
| | | h: { |
| | | type: [String, Number], |
| | | default: null |
| | | }, |
| | | top: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | right: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | bottom: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | }, |
| | | left: { |
| | | type: [String, Number], |
| | | default: 0 |
| | | } |
| | | }, |
| | | computed: { |
| | | viewStyle() { |
| | | const style = {} |
| | | const addStyle = uni.$u.addStyle(this.width || this.w) && (style.width = addStyle(this.width || this.w))(this.height || this.h) && (style.height = addStyle(this.height || this.h))(this.margin || this.m) && (style.margin = addStyle(this.margin || this.m))(this.marginTop || this.mt) && (style.marginTop = addStyle(this.marginTop || this.mt))(this.marginRight || this.mr) && (style.marginRight = addStyle(this.marginRight || this.mr))(this.marginBottom || this.mb) && (style.marginBottom = addStyle(this.marginBottom || this.mb))(this.marginLeft || this.ml) && (style.marginLeft = addStyle(this.marginLeft || this.ml))(this.padding || this.p) && (style.padding = addStyle(this.padding || this.p))(this.paddingTop || this.pt) && (style.paddingTop = addStyle(this.paddingTop || this.pt))(this.paddingRight || this.pr) && (style.paddingRight = addStyle(this.paddingRight || this.pr))(this.paddingBottom || this.pb) && (style.paddingBottom = addStyle(this.paddingBottom || this.pb))(this.paddingLeft || this.pl) && (style.paddingLeft = addStyle(this.paddingLeft || this.pl))(this.color || this.c) && (style.color = this.color || this.c)(this.fontSize || this.fs) && (style.fontSize = this.fontSize || this.fs)(this.borderRadius || this.radius) && (style.borderRadius = this.borderRadius || this.radius)(this.position || this.pos) && (this.position = this.position || this.pos)(this.flexDirection || this.fd) && (this.flexDirection = this.flexDirection || this.fd)(this.justifyContent || jc) && (this.justifyContent = this.justifyContent || jc)(this.alignItems || ai) && (this.alignItems = this.alignItems || ai) |
| | | |
| | | return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle)) |
| | | } |
| | | }, |
| | | methods: { |
| | | // è·åmarginæè
paddingçåä½ï¼æ¯å¦padding: 0 20转为padding: 0 20px |
| | | getUnit(unit = '') { |
| | | // ååºä¸¤ç«¯ç©ºæ ¼ï¼åéææ°ç»ï¼å对æ°ç»çæ¯ä¸ªå
ç´ æ·»å åä½ï¼æåååå¹¶æå符串 |
| | | return uni.$u.trim(unit).split(' ').map((item) => uni.$u.addUnit(item)).join(' ') |
| | | } |
| | | } |
| | | } |