bug
jiangping
2023-11-07 64b432916af9c9218ab3f3eca614e26c542142ae
minipro_standard/uni_modules/uview-ui/components/u-line/u-line.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,62 @@
<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>