From 68c5ef7d9fea3f911e250fb5f8b300bc76099e49 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 26 十月 2023 13:55:49 +0800
Subject: [PATCH] 小程序
---
minipro_standard/uni_modules/uview-ui/components/u-index-item/u-index-item.vue | 87 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 87 insertions(+), 0 deletions(-)
diff --git a/minipro_standard/uni_modules/uview-ui/components/u-index-item/u-index-item.vue b/minipro_standard/uni_modules/uview-ui/components/u-index-item/u-index-item.vue
new file mode 100644
index 0000000..0bc7fb3
--- /dev/null
+++ b/minipro_standard/uni_modules/uview-ui/components/u-index-item/u-index-item.vue
@@ -0,0 +1,87 @@
+<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() {
+ // 瀛愮粍浠秛-index-anchor鐨勫疄渚�
+ this.anchor = {}
+ },
+ mounted() {
+ this.init()
+ },
+ methods: {
+ init() {
+ // 姝ゅ浼氭椿鍔ㄧ埗缁勪欢瀹炰緥锛屽苟璧嬪�肩粰瀹炰緥鐨刾arent灞炴��
+ this.getParentData('u-index-list')
+ if (!this.parent) {
+ return uni.$u.error('u-index-item蹇呴』瑕佹惌閰島-index-list缁勪欢浣跨敤')
+ }
+ uni.$u.sleep().then(() =>{
+ this.getIndexItemRect().then(size => {
+ // 鐢变簬瀵硅薄鐨勫紩鐢ㄧ壒鎬э紝姝ゅ浼氬悓鏃剁敓鏁堝埌鐖剁粍浠剁殑children鏁扮粍鐨勬湰瀹炰緥鐨則op灞炴�т腑锛屼緵鐖剁粍浠跺垽鏂鍙�
+ 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>
--
Gitblit v1.9.3