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-anchor/u-index-anchor.vue | 91 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/minipro_standard/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue b/minipro_standard/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue
index e69de29..b95ddef 100644
--- a/minipro_standard/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue
+++ b/minipro_standard/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue
@@ -0,0 +1,91 @@
+<template>
+ <!-- #ifdef APP-NVUE -->
+ <header>
+ <!-- #endif -->
+ <view
+ class="u-index-anchor u-border-bottom"
+ :ref="`u-index-anchor-${text}`"
+ :style="{
+ height: $u.addUnit(height),
+ backgroundColor: bgColor
+ }"
+ >
+ <text
+ class="u-index-anchor__text"
+ :style="{
+ fontSize: $u.addUnit(size),
+ color: color
+ }"
+ >{{ text }}</text>
+ </view>
+ <!-- #ifdef APP-NVUE -->
+ </header>
+ <!-- #endif -->
+</template>
+
+<script>
+ import props from './props.js';
+ // #ifdef APP-NVUE
+ const dom = uni.requireNativePlugin('dom')
+ // #endif
+ /**
+ * IndexAnchor 鍒楄〃閿氱偣
+ * @description
+ * @tutorial https://uviewui.com/components/indexList.html
+ * @property {String | Number} text 鍒楄〃閿氱偣鏂囨湰鍐呭
+ * @property {String} color 鍒楄〃閿氱偣鏂囧瓧棰滆壊 ( 榛樿 '#606266' )
+ * @property {String | Number} size 鍒楄〃閿氱偣鏂囧瓧澶у皬锛屽崟浣嶉粯璁x ( 榛樿 14 )
+ * @property {String} bgColor 鍒楄〃閿氱偣鑳屾櫙棰滆壊 ( 榛樿 '#dedede' )
+ * @property {String | Number} height 鍒楄〃閿氱偣楂樺害锛屽崟浣嶉粯璁x ( 榛樿 32 )
+ * @example <u-index-anchor :text="indexList[index]"></u-index-anchor>
+ */
+ export default {
+ name: 'u-index-anchor',
+ mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
+ data() {
+ return {
+ }
+ },
+ mounted() {
+ this.init()
+ },
+ methods: {
+ init() {
+ // 姝ゅ浼氭椿鍔ㄧ埗缁勪欢瀹炰緥锛屽苟璧嬪�肩粰瀹炰緥鐨刾arent灞炴��
+ const indexList = uni.$u.$parent.call(this, 'u-index-list')
+ if (!indexList) {
+ return uni.$u.error('u-index-anchor蹇呴』瑕佹惌閰島-index-list缁勪欢浣跨敤')
+ }
+ // 灏嗗綋鍓嶅疄渚嬫斁鍏ュ埌u-index-list涓�
+ indexList.anchors.push(this)
+ const indexListItem = uni.$u.$parent.call(this, 'u-index-item')
+ // #ifndef APP-NVUE
+ // 鍙湁鍦ㄩ潪nvue涓嬶紝u-index-anchor鎵嶆槸宓屽鍦╱-index-item涓殑
+ if (!indexListItem) {
+ return uni.$u.error('u-index-anchor蹇呴』瑕佹惌閰島-index-item缁勪欢浣跨敤')
+ }
+ // 璁剧疆u-index-item鐨刬d涓篴nchor鐨則ext鏍囪瘑绗︼紝鍥犱负闈瀗vue涓嬫粴鍔ㄥ垪琛ㄩ渶瑕佷緷璧杝croll-view婊氬姩鍒板厓绱犵殑鐗规��
+ indexListItem.id = this.text.charCodeAt(0)
+ // #endif
+ }
+ },
+ }
+</script>
+
+<style lang="scss" scoped>
+ @import "../../libs/css/components.scss";
+
+ .u-index-anchor {
+ position: sticky;
+ top: 0;
+ @include flex;
+ align-items: center;
+ padding-left: 15px;
+ z-index: 1;
+
+ &__text {
+ @include flex;
+ align-items: center;
+ }
+ }
+</style>
--
Gitblit v1.9.3