Blame view

node_modules/uview-ui/components/u-index-anchor/u-index-anchor.vue 2.09 KB
c7add6cf   “wangming”   初始版本开发完毕
1
  <template>
25852764   unknown   s
2
3
4
5
6
7
8
9
10
11
  	<!-- 支付宝小程序使用$u.getRect()获取组件的根元素尺寸,所以在外面套一个"壳" -->
  	<view>
  		<view class="u-index-anchor-wrapper" :id="$u.guid()" :style="[wrapperStyle]">
  			<view class="u-index-anchor " :class="[active ? 'u-index-anchor--active' : '']" :style="[customAnchorStyle]">
  				<slot v-if="useSlot" />
  				<block v-else>
  					<text>{{ index }}</text>
  				</block>
  			</view>
  		</view>
c7add6cf   “wangming”   初始版本开发完毕
12
  	</view>
c7add6cf   “wangming”   初始版本开发完毕
13
14
15
  </template>
  
  <script>
c7add6cf   “wangming”   初始版本开发完毕
16
  	/**
25852764   unknown   s
17
18
19
20
21
22
23
24
  	 * indexAnchor 索引列表锚点
  	 * @description 通过折叠面板收纳内容区域,搭配<u-index-anchor>使用
  	 * @tutorial https://www.uviewui.com/components/indexList.html#indexanchor-props
  	 * @property {Boolean} use-slot 是否使用自定义内容的插槽(默认false
  	 * @property {String Number} index 索引字符,如果定义了use-slot,此参数自动失效
  	 * @property {Object} custStyle 自定义样式,对象形式,如"{color: 'red'}"
  	 * @event {Function} default 锚点位置显示内容,默认为索引字符
  	 * @example <u-index-anchor :index="item" />
c7add6cf   “wangming”   初始版本开发完毕
25
26
  	 */
  	export default {
25852764   unknown   s
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
  		name: "u-index-anchor",
  		props: {
  			useSlot: {
  				type: Boolean,
  				default: false
  			},
  			index: {
  				type: String,
  				default: ''
  			},
  			customStyle: {
  				type: Object,
  				default () {
  					return {}
  				}
  			}
  		},
c7add6cf   “wangming”   初始版本开发完毕
44
45
  		data() {
  			return {
25852764   unknown   s
46
47
48
  				active: false,
  				wrapperStyle: {},
  				anchorStyle: {}
c7add6cf   “wangming”   初始版本开发完毕
49
50
  			}
  		},
25852764   unknown   s
51
52
  		created() {
  			this.parent = false;
c7add6cf   “wangming”   初始版本开发完毕
53
  		},
25852764   unknown   s
54
55
56
57
58
  		mounted() {
  			this.parent = this.$u.$parent.call(this, 'u-index-list');
  			if(this.parent) {
  				this.parent.children.push(this);
  				this.parent.updateData();
c7add6cf   “wangming”   初始版本开发完毕
59
60
  			}
  		},
25852764   unknown   s
61
62
63
64
65
  		computed: {
  			customAnchorStyle() {
  				return Object.assign(this.anchorStyle, this.customStyle);
  			}
  		}
c7add6cf   “wangming”   初始版本开发完毕
66
67
68
69
  	}
  </script>
  
  <style lang="scss" scoped>
25852764   unknown   s
70
71
  	@import "../../libs/css/style.components.scss";
  	
c7add6cf   “wangming”   初始版本开发完毕
72
  	.u-index-anchor {
25852764   unknown   s
73
74
75
76
77
78
79
80
81
  		box-sizing: border-box;
  		padding: 14rpx 24rpx;
  		color: #606266;
  		width: 100%;
  		font-weight: 500;
  		font-size: 28rpx;
  		line-height: 1.2;
  		background-color: rgb(245, 245, 245);
  	}
c7add6cf   “wangming”   初始版本开发完毕
82
  
25852764   unknown   s
83
84
85
86
87
  	.u-index-anchor--active {
  		right: 0;
  		left: 0;
  		color: #2979ff;
  		background-color: #fff;
c7add6cf   “wangming”   初始版本开发完毕
88
89
  	}
  </style>