¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <!-- #ifdef APP-NVUE --> |
| | | <cell ref="u-index-item"> |
| | | <!-- #endif --> |
| | | <view |
| | | class="u-index-item" |
| | | :id="`u-index-item-${id}`" |
| | | :class="[`u-index-item-${id}`]" |
| | | > |
| | | <slot /> |
| | | </view> |
| | | <!-- #ifdef APP-NVUE --> |
| | | </cell> |
| | | <!-- #endif --> |
| | | </template> |
| | | |
| | | <script> |
| | | import props from './props.js'; |
| | | // #ifdef APP-NVUE |
| | | // ç±äºweex为é¿éçKPIä¸ç»©èæ ¸ç产ç©ï¼æä»¥ä¸æ¯æç¾åæ¯åä½ï¼è¿ééè¦éè¿domæ¥è¯¢ç»ä»¶ç宽度 |
| | | const dom = uni.requireNativePlugin('dom') |
| | | // #endif |
| | | /** |
| | | * IndexItem |
| | | * @description |
| | | * @tutorial https://uviewui.com/components/indexList.html |
| | | * @property {String} |
| | | * @event {Function} |
| | | * @example |
| | | */ |
| | | export default { |
| | | name: 'u-index-item', |
| | | mixins: [uni.$u.mpMixin, uni.$u.mixin,props], |
| | | data() { |
| | | return { |
| | | // æ¬ç»ä»¶å°æ»å¨æ¡é¡¶é¨çè·ç¦» |
| | | top: 0, |
| | | height: 0, |
| | | id: '' |
| | | } |
| | | }, |
| | | created() { |
| | | // åç»ä»¶u-index-anchorçå®ä¾ |
| | | this.anchor = {} |
| | | }, |
| | | mounted() { |
| | | this.init() |
| | | }, |
| | | methods: { |
| | | init() { |
| | | // æ¤å¤ä¼æ´»å¨ç¶ç»ä»¶å®ä¾ï¼å¹¶èµå¼ç»å®ä¾çparent屿§ |
| | | this.getParentData('u-index-list') |
| | | if (!this.parent) { |
| | | return uni.$u.error('u-index-itemå¿
é¡»è¦æé
u-index-listç»ä»¶ä½¿ç¨') |
| | | } |
| | | uni.$u.sleep().then(() =>{ |
| | | this.getIndexItemRect().then(size => { |
| | | // ç±äºå¯¹è±¡çå¼ç¨ç¹æ§ï¼æ¤å¤ä¼åæ¶çæå°ç¶ç»ä»¶çchildrenæ°ç»çæ¬å®ä¾çtop屿§ä¸ï¼ä¾ç¶ç»ä»¶å¤æè¯»å |
| | | this.top = Math.ceil(size.top) |
| | | this.height = Math.ceil(size.height) |
| | | }) |
| | | }) |
| | | }, |
| | | getIndexItemRect() { |
| | | return new Promise(resolve => { |
| | | // #ifndef APP-NVUE |
| | | this.$uGetRect('.u-index-item').then(size => { |
| | | resolve(size) |
| | | }) |
| | | // #endif |
| | | |
| | | // #ifdef APP-NVUE |
| | | const ref = this.$refs['u-index-item'] |
| | | dom.getComponentRect(ref, res => { |
| | | resolve(res.size) |
| | | }) |
| | | // #endif |
| | | }) |
| | | } |
| | | }, |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import "../../libs/css/components.scss"; |
| | | |
| | | </style> |