此篇仅作日常问题记录,有问题欢迎大家发言,共同探讨学习。
页面呈现效果:
这个案例有点类似fixed悬浮了,具体问题我也不知道为什么跟官网演示的不同。
案例具体代码:
<template>
<view>
<u-sticky offset-top="360">
<view>
<uni-segmented-control :current="current" :values="Arr" @clickItem="onClickItem"
activeColor="#32CD32"></uni-segmented-control>
</view>
</u-sticky>
<view v-for="i in 15">
<view style="width: 100%;height: 80px;background-color:bisque;margin:10px 0px;box-sizing: border-box;">{{ i }}</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
current: 0,
Arr: ['第一', '第二', '第三'],
}
},
methods: {
onClickItem(e) {
uni.showToast({
title:'点击了-'+this.Arr[e.currentIndex],
icon:'success'
})
},
},
}
</script>
<style lang="scss">
::v-deep .segmented-control__item--button--first {
border-bottom-left-radius: 0px !important;
border-top-left-radius: 0px !important;
}
/deep/ .segmented-control__item--button--last {
border-top-right-radius: 0px !important;
border-bottom-right-radius: 0px !important;
}
::v-deep .segmented-control__item--button {
border-top-width: 2px !important;
border-bottom-width: 1px !important;
border-right-width: 1px !important;
border-left-width: 0 !important;
background: white !important;
}
::v-deep .segmented-control__item--button--active {
background-color: orange !important;
}
::v-deep .u-dropdown__menu__item {
background: white !important;
}
</style>