¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view |
| | | class="u-line" |
| | | :style="[lineStyle]" |
| | | > |
| | | |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import props from './props.js'; |
| | | /** |
| | | * line çº¿æ¡ |
| | | * @description æ¤ç»ä»¶ä¸è¬ç¨äºæ¾ç¤ºä¸æ ¹çº¿æ¡ï¼ç¨äºåéå
容åï¼ææ¨ªååç«åä¸¤ç§æ¨¡å¼ï¼ä¸è½è®¾ç½®0.5px线æ¡ï¼ä½¿ç¨ä¹å¾ç®å |
| | | * @tutorial https://www.uviewui.com/components/line.html |
| | | * @property {String} color 线æ¡çé¢è² ( é»è®¤ '#d6d7d9' ) |
| | | * @property {String | Number} length é¿åº¦ï¼ç«åæ¶è¡¨ç°ä¸ºé«åº¦ï¼æ¨ªåæ¶è¡¨ç°ä¸ºé¿åº¦ï¼å¯ä»¥ä¸ºç¾åæ¯ï¼å¸¦pxåä½çå¼ç ( é»è®¤ '100%' ) |
| | | * @property {String} direction 线æ¡çæ¹åï¼row-横åï¼col-ç«å (é»è®¤ 'row' ) |
| | | * @property {Boolean} hairline æ¯å¦æ¾ç¤ºç»çº¿æ¡ (é»è®¤ true ) |
| | | * @property {String | Number} margin 线æ¡ä¸ä¸ä¸å·¦å³å
ç´ çé´è·ï¼å符串形å¼ï¼å¦"30px" (é»è®¤ 0 ) |
| | | * @property {Boolean} dashed æ¯å¦è线ï¼true-è线ï¼false-å®çº¿ (é»è®¤ false ) |
| | | * @property {Object} customStyle å®ä¹éè¦ç¨å°çå¤é¨æ ·å¼ |
| | | * @example <u-line color="red"></u-line> |
| | | */ |
| | | export default { |
| | | name: 'u-line', |
| | | mixins: [uni.$u.mpMixin, uni.$u.mixin,props], |
| | | computed: { |
| | | lineStyle() { |
| | | const style = {} |
| | | style.margin = this.margin |
| | | // å¦ææ¯æ°´å¹³çº¿æ¡ï¼è¾¹æ¡é«åº¦ä¸º1pxï¼åéè¿transform缩å°ä¸åï¼å°±æ¯0.5pxäº |
| | | if (this.direction === 'row') { |
| | | // æ¤å¤éç¨å
¼å®¹åå¼åï¼å
¼å®¹nvueçåæ³ |
| | | style.borderBottomWidth = '1px' |
| | | style.borderBottomStyle = this.dashed ? 'dashed' : 'solid' |
| | | style.width = uni.$u.addUnit(this.length) |
| | | if (this.hairline) style.transform = 'scaleY(0.5)' |
| | | } else { |
| | | // 妿æ¯ç«å线æ¡ï¼è¾¹æ¡å®½åº¦ä¸º1pxï¼åéè¿transform缩å°ä¸åï¼å°±æ¯0.5pxäº |
| | | style.borderLeftWidth = '1px' |
| | | style.borderLeftStyle = this.dashed ? 'dashed' : 'solid' |
| | | style.height = uni.$u.addUnit(this.length) |
| | | if (this.hairline) style.transform = 'scaleX(0.5)' |
| | | } |
| | | |
| | | style.borderColor = this.color |
| | | return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle)) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "../../libs/css/components.scss"; |
| | | |
| | | .u-line { |
| | | /* #ifndef APP-NVUE */ |
| | | vertical-align: middle; |
| | | /* #endif */ |
| | | } |
| | | </style> |