¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view |
| | | class="u-empty" |
| | | :style="[emptyStyle]" |
| | | v-if="show" |
| | | > |
| | | <u-icon |
| | | v-if="!isSrc" |
| | | :name="mode === 'message' ? 'chat' : `empty-${mode}`" |
| | | :size="iconSize" |
| | | :color="iconColor" |
| | | margin-top="14" |
| | | ></u-icon> |
| | | <image |
| | | v-else |
| | | :style="{ |
| | | width: $u.addUnit(width), |
| | | height: $u.addUnit(height), |
| | | }" |
| | | :src="icon" |
| | | mode="widthFix" |
| | | ></image> |
| | | <text |
| | | class="u-empty__text" |
| | | :style="[textStyle]" |
| | | >{{text ? text : icons[mode]}}</text> |
| | | <view class="u-empty__wrap" v-if="$slots.default || $slots.$default"> |
| | | <slot /> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import props from './props.js'; |
| | | |
| | | /** |
| | | * empty å
容为空 |
| | | * @description 该ç»ä»¶ç¨äºéè¦å è½½å
容ï¼ä½æ¯å è½½ç第ä¸é¡µæ°æ®å°±ä¸ºç©ºï¼æç¤ºä¸ä¸ª"没æå
容"çåºæ¯ï¼ æä»¬ç²¾å¿æéäºåå ä¸ªåºæ¯ç徿 ï¼æ¹ä¾¿æ¨ä½¿ç¨ã |
| | | * @tutorial https://www.uviewui.com/components/empty.html |
| | | * @property {String} icon å
ç½®å¾æ åç§°ï¼æå¾çè·¯å¾ï¼å»ºè®®ç»å¯¹è·¯å¾ |
| | | * @property {String} text æç¤ºæå |
| | | * @property {String} textColor æåé¢è² (é»è®¤ '#c0c4cc' ) |
| | | * @property {String | Number} textSize æåå¤§å° ï¼é»è®¤ 14 ï¼ |
| | | * @property {String} iconColor 徿 çé¢è² ï¼é»è®¤ '#c0c4cc' ï¼ |
| | | * @property {String | Number} iconSize 徿 çå¤§å° ï¼é»è®¤ 90 ï¼ |
| | | * @property {String} mode éæ©é¢ç½®ç徿 ç±»å ï¼é»è®¤ 'data' ï¼ |
| | | * @property {String | Number} width 徿 宽度ï¼åä½px ï¼é»è®¤ 160 ï¼ |
| | | * @property {String | Number} height 徿 é«åº¦ï¼åä½px ï¼é»è®¤ 160 ï¼ |
| | | * @property {Boolean} show æ¯å¦æ¾ç¤ºç»ä»¶ ï¼é»è®¤ true ï¼ |
| | | * @property {String | Number} marginTop ç»ä»¶è·ç¦»ä¸ä¸ä¸ªå
ç´ ä¹é´çè·ç¦»ï¼é»è®¤pxåä½ ï¼é»è®¤ 0 ï¼ |
| | | * @property {Object} customStyle å®ä¹éè¦ç¨å°çå¤é¨æ ·å¼ |
| | | * |
| | | * @event {Function} click ç¹å»ç»ä»¶æ¶è§¦å |
| | | * @event {Function} close ç¹å»å
³éæé®æ¶è§¦å |
| | | * @example <u-empty text="æè°ä¼äººï¼å¨æ°´ä¸æ¹" mode="list"></u-empty> |
| | | */ |
| | | export default { |
| | | name: "u-empty", |
| | | mixins: [uni.$u.mpMixin, uni.$u.mixin, props], |
| | | data() { |
| | | return { |
| | | icons: { |
| | | car: 'è´ç©è½¦ä¸ºç©º', |
| | | page: '页é¢ä¸åå¨', |
| | | search: '没ææç´¢ç»æ', |
| | | address: 'æ²¡ææ¶è´§å°å', |
| | | wifi: '没æWiFi', |
| | | order: '订å为空', |
| | | coupon: '没æä¼æ å¸', |
| | | favor: 'ææ æ¶è', |
| | | permission: 'æ æé', |
| | | history: 'æ åå²è®°å½', |
| | | news: 'æ æ°é»å表', |
| | | message: 'æ¶æ¯å表为空', |
| | | list: 'å表为空', |
| | | data: 'æ°æ®ä¸ºç©º', |
| | | comment: 'ææ è¯è®º', |
| | | } |
| | | } |
| | | }, |
| | | computed: { |
| | | // ç»ä»¶æ ·å¼ |
| | | emptyStyle() { |
| | | const style = {} |
| | | style.marginTop = uni.$u.addUnit(this.marginTop) |
| | | // åå¹¶customStyleæ ·å¼ï¼æ¤åæ°éè¿mixinä¸çpropsä¼ é |
| | | return uni.$u.deepMerge(uni.$u.addStyle(this.customStyle), style) |
| | | }, |
| | | // ææ¬æ ·å¼ |
| | | textStyle() { |
| | | const style = {} |
| | | style.color = this.textColor |
| | | style.fontSize = uni.$u.addUnit(this.textSize) |
| | | return style |
| | | }, |
| | | // 夿iconæ¯å¦å¾çè·¯å¾ |
| | | isSrc() { |
| | | return this.icon.indexOf('/') >= 0 |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import '../../libs/css/components.scss'; |
| | | $u-empty-text-margin-top:20rpx !default; |
| | | $u-empty-slot-margin-top:20rpx !default; |
| | | |
| | | .u-empty { |
| | | @include flex; |
| | | flex-direction: column; |
| | | justify-content: center; |
| | | align-items: center; |
| | | |
| | | &__text { |
| | | @include flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | margin-top: $u-empty-text-margin-top; |
| | | } |
| | | } |
| | | .u-slot-wrap { |
| | | @include flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | margin-top:$u-empty-slot-margin-top; |
| | | } |
| | | </style> |