From d1448cb0ef10f358bb7bddb4e1ec268515e0b787 Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期二, 15 七月 2025 11:46:57 +0800 Subject: [PATCH] 项目初始化 --- uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue | 91 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 91 insertions(+), 0 deletions(-) diff --git a/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue b/uni_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue new file mode 100644 index 0000000..b95ddef --- /dev/null +++ b/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