¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view |
| | | class="u-row" |
| | | ref="u-row" |
| | | :style="[rowStyle]" |
| | | @tap="clickHandler" |
| | | > |
| | | <slot /> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | // #ifdef APP-NVUE |
| | | const dom = uni.requireNativePlugin('dom') |
| | | // #endif |
| | | import props from './props.js'; |
| | | /** |
| | | * Row æ
æ ¼ç³»ç»ä¸çè¡ |
| | | * @description éè¿åºç¡ç 12 åæ ï¼è¿
éç®ä¾¿å°å建å¸å± |
| | | * @tutorial https://www.uviewui.com/components/layout.html |
| | | * @property {String | Number} gutter æ
æ ¼é´éï¼å·¦å³å为æ¤å¼çä¸åï¼åä½px (é»è®¤ 0 ) |
| | | * @property {String} justify æ°´å¹³æåæ¹å¼(微信å°ç¨åºæä¸æ¯æ) å¯éå¼ä¸º`start`(æ`flex-start`)ã`end`(æ`flex-end`)ã`center`ã`around`(æ`space-around`)ã`between`(æ`space-between`) (é»è®¤ 'start' ) |
| | | * @property {String} align åç´æåæ¹å¼ (é»è®¤ 'center' ) |
| | | * @property {Object} customStyle å®ä¹éè¦ç¨å°çå¤é¨æ ·å¼ |
| | | * |
| | | * @event {Function} click row被ç¹å» |
| | | * @example <u-row justify="space-between" customStyle="margin-bottom: 10px"></u-row> |
| | | */ |
| | | export default { |
| | | name: "u-row", |
| | | mixins: [uni.$u.mpMixin, uni.$u.mixin, props], |
| | | data() { |
| | | return { |
| | | |
| | | } |
| | | }, |
| | | computed: { |
| | | uJustify() { |
| | | if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify |
| | | else if (this.justify == 'around' || this.justify == 'between') return 'space-' + this.justify |
| | | else return this.justify |
| | | }, |
| | | uAlignItem() { |
| | | if (this.align == 'top') return 'flex-start' |
| | | if (this.align == 'bottom') return 'flex-end' |
| | | else return this.align |
| | | }, |
| | | rowStyle() { |
| | | const style = { |
| | | alignItems: this.uAlignItem, |
| | | justifyContent: this.uJustify |
| | | } |
| | | // éè¿ç»u-rowå·¦å³ä¸¤è¾¹çè´å¤è¾¹è·ï¼æ¶é¤u-col卿gutteræ¶ï¼ç¬¬ä¸ä¸ªåæåä¸ä¸ªå
ç´ çå·¦å
è¾¹è·åå³å
è¾¹è·é æçå½±å |
| | | if(this.gutter) { |
| | | style.marginLeft = uni.$u.addUnit(-Number(this.gutter)/2) |
| | | style.marginRight = uni.$u.addUnit(-Number(this.gutter)/2) |
| | | } |
| | | return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle)) |
| | | } |
| | | }, |
| | | methods: { |
| | | clickHandler(e) { |
| | | this.$emit('click') |
| | | }, |
| | | async getComponentWidth() { |
| | | // å»¶æ¶ä¸å®æ¶é´ï¼ä»¥ç¡®ä¿èç¹æ¸²æå®æ |
| | | await uni.$u.sleep() |
| | | return new Promise(resolve => { |
| | | // uViewå°è£
çè·åèç¹çæ¹æ³ï¼è¯¦è§ææ¡£ |
| | | // #ifndef APP-NVUE |
| | | this.$uGetRect('.u-row').then(res => { |
| | | resolve(res.width) |
| | | }) |
| | | // #endif |
| | | // #ifdef APP-NVUE |
| | | // nvueçdom模åç¨äºè·åèç¹ |
| | | dom.getComponentRect(this.$refs['u-row'], (res) => { |
| | | resolve(res.size.width) |
| | | }) |
| | | // #endif |
| | | }) |
| | | }, |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "../../libs/css/components.scss"; |
| | | |
| | | .u-row { |
| | | @include flex; |
| | | } |
| | | </style> |