- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章uniapp实现可滑动选项卡由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文实例为大家分享了uniapp实现可滑动选项卡的具体代码,供大家参考,具体内容如下 。
tabControl-tag.vue 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
<
template
name
=
"tabControl"
>
<
scroll-view
scroll-x
=
"true"
:style
=
"'background-color:'+bgc+';top:'+top+'px;'"
:class
=
"fixed?'fxied':''"
:scroll-left
=
'scrollLeft'
scroll-with-animation
id
=
"tabcard"
>
<
view
class
=
"tabList"
:style
=
"isEqually?'display: flex;justify-content: space-between;padding-left:0;':''"
>
<
view
:class
=
"'tabItem'+(currentIndex==index?' thisOpenSelect':'')"
:style
=
"isEqually? 'width:'+windowWidth/values.length+'px;margin-right:0;':''"
v-for
=
"(item,index) in values"
:id
=
"'item'+index"
:key
=
'index'
@
click
=
"_onClick(index)"
>
<
text
:style
=
"(currentIndex==index?'font-size:'+activeSize+'rpx;color:'+activeColor:'font-size:'+itemSize+'rpx')"
>{{item}}</
text
>
<
view
class
=
"activeLine"
:style
=
"{width: lineWidth+'rpx'}"
></
view
>
</
view
>
</
view
>
</
scroll-view
>
</
template
>
<
script
>
export default {
name:'tabControl',
props:{
current: {
type: Number,
default: 0
},
values: {
type: Array,
default () {
return []
}
},
bgc:{
type:String,
default:''
},
fixed:{
type:Boolean,
default:false
},
scrollFlag:{
type:Boolean,
default:false
},
lineWidth:{
type:Number,
default: 100
},
itemSize:{
type:Number,
default: 30
},
activeSize:{
type:Number,
default: 32
},
activeColor:{
type:String,
default:''
},
top:{
type:Number,
default: 0
},
isEqually:{
type:Boolean,
default:false
}
},
data() {
return {
currentIndex: 0,
windowWidth:0, //设备宽度
leftList:[], //选项距离左边的距离
widthList:[], //选项宽度
scrollLeft:0, //移动距离
newScroll:0, //上一次移动距离(用来判断是左滑还是右滑)
wornScroll:0, //上一次移动距离(用来判断是左滑还是右滑)
};
},
created(){
},
mounted(){
setTimeout(()=>{
uni.createSelectorQuery().in(this).select("#tabcard").boundingClientRect((res)=>{
this.$emit('getTabCardHeight', {height:res.height})
}).exec()
uni.getSystemInfo({
success: (res)=> {
this.windowWidth = res.windowWidth;
// console.log(this.windowWidth);
this.values.forEach((i,v)=>{
let info = uni.createSelectorQuery().in(this);
info.select("#item"+v).boundingClientRect((res)=>{
// 获取第一个元素到左边的距离
// if(v==0){
// this.startLenght = res.left
// }
this.widthList.push(res.width)
this.leftList.push(res.left)
}).exec()
})
// console.log(this.leftList)
// console.log(this.widthList)
}
});
})
},
created() {
this.currentIndex = this.current
if(this.scrollFlag){
setTimeout(()=>{
this.tabListScroll(this.current)
},300)
}
},
watch: {
current(val) {
if (val !== this.currentIndex) {
this.currentIndex = val
if(this.scrollFlag){
this.tabListScroll(val)
}
}
},
},
methods: {
_onClick(index) {
if (this.currentIndex !== index) {
this.currentIndex = index
this.$emit('clickItem', {currentIndex:index})
// 开启滚动
if(this.scrollFlag){
this.tabListScroll(index)
}
}
},
// 选项移动
tabListScroll(index){
let scoll = 0;
this.wornScroll = index;
// this.wornScroll-this.newScroll>0 在向左滑 ←←←←←
if(this.wornScroll-this.newScroll>0){
for(let i = 0;i<
this.leftList.length
;i++){
if(i>1&&i==this.currentIndex){
scoll = this.leftList[i-1]
}
}
// console.log('在向左滑',scoll)
}else{
if(index>1){
for(let i = 0;i<
this.leftList.length
;i++){
if(i<index-1){
scoll
=
this
.leftList[i]
}
}
}else{
scoll
=
0
}
// console.log('在向右滑')
}
this.newScroll
= this.wornScroll;
this.scrollLeft
=
scoll
;
}
}
}
</script>
<
style
lang
=
"less"
scoped>
.fxied{
position: fixed;
z-index: 2;
}
.tabList{
padding-top: 24rpx;
padding-left: 24rpx;
padding-bottom: 8rpx;
white-space: nowrap;
text-align: center;
.tabItem{
margin-right: 60rpx;
display: inline-block;
position: relative;
text{
// font-size: 30rpx;
line-height: 44rpx;
color: #666;
transition: all 0.3s ease 0s;
}
.activeLine{
// width: 48rpx;
height: 8rpx;
border-radius: 4rpx;
background-color: #F57341;
margin-top: 8rpx;
margin-left: 50%;
transform: translateX(-50%);
opacity: 0;
transition: all 0.3s ease 0s;
}
}
.tabItem:first-child{
// margin-left: 22rpx;
}
.tabItem:last-child{
margin-right: 24rpx;
}
.thisOpenSelect{
text{
color: #333;
font-weight:600;
// font-size: 32rpx;
}
.activeLine{
opacity: 1;
}
}
}
</
style
>
|
页面引用 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
<
template
>
<
view
class
=
"page"
>
<
tabControl
:current
=
"current"
:values
=
"items"
bgc
=
"#fff"
:fixed
=
"true"
:scrollFlag
=
"true"
:isEqually
=
"false"
@
clickItem
=
"onClickItem"
></
tabControl
>
<!-- 使用 swiper 配合 滑动切换 -->
<
swiper
class
=
"swiper"
style
=
"height: 100%;"
@
change
=
"scollSwiper"
:current
=
"current"
>
<
swiper-item
v-for
=
"(item, index) in items"
:key
=
"index"
>
<!-- 使用 scroll-view 来滚动内容区域 -->
<
scroll-view
scroll-y
=
"true"
style
=
"height: 100%;"
>{{ item }}</
scroll-view
>
</
swiper-item
>
</
swiper
>
</
view
>
</
template
>
<
script
>
import tabControl from '@/components/tabControl-tag/tabControl-tag.vue';
export default {
components: { tabControl },
data() {
return {
items: ['业绩统计', '选项卡2', '选项卡3', '选项卡4', '选项卡5'],
current: 0
};
},
onLoad() {},
methods: {
onClickItem(val) {
this.current = val.currentIndex;
},
scollSwiper(e) {
this.current = e.target.current;
}
}
};
</
script
>
<
style
>
page {
height: 100%;
}
.page {
padding-top: 98rpx;
height: 100%;
}
</
style
>
|
1.使用方式:
scrollFlag --是否开启选项滚动(true -开启 false -关闭) 根据自己需求如果选项长度超出屏幕长度 建议开启 fixed --固定定位 bgc --背景色 values --选项数组 current --当前选中选项索引 isEqually --是否开启选项平分宽度(true,false) lineWidth --下划线长度(在非平分选项状态下 可能会影响选项盒子的宽度-自行调试想要的效果,默认为48rpx) itemSize --未选中选项字体大小(默认为30rpx) activeSize --选中选项字体大小(默认为32rpx) activeColor --选中选项字体颜色(默认#333) top --选项卡固定定位 自定义top距离 。
注意:
使用fixed固定头部的时候 要将页面整体padding-top:98rpx;不然会盖住内容区域。 使用swiper实现滑动切换时 要将page 高度设置100% swiper高度100% 才可以全屏滑动切换 。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:https://blog.csdn.net/weixin_44816309/article/details/106661706 。
最后此篇关于uniapp实现可滑动选项卡的文章就讲到这里了,如果你想了解更多关于uniapp实现可滑动选项卡的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
这是在我的 MainActivity 中用作 BroadcastReceiver 的代码 mRegistrationBroadcastReceiver = new BroadcastRecei
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我想在大部分时间隐藏 UISearchBar,只在用户需要时调用它来显示。 我在 Interface Builder 中放置了一个 UISearchBar 并将其隐藏在 View 后面,当用户单击按钮
我有一个包含 CCMenuItemImage 的菜单(“myMenu”)。我希望此菜单能够检测手指滑动并相应地滑动。 我的问题是 CCMenuItemImage 似乎吸收了触摸事件。当用户触摸 CCM
我正在寻找一个简单的 jQuery 或 Javascript 解决方案,以使导航侧边栏在用户向下滚动页面时顺利跟随用户。像这里一样:http://ucon-acrobatics.com/shop/ 任
我有一个 ListView 控件来显示项目,我想提供一个滑动/滑动手势来选择一个项目。我用 GestureRecognizer类来识别交叉滑动手势,但我还想通过水平移动选择的项目来为这个手势设置动画。
我想将 String 行标记化为标记(存储到 String 表中),并且我只能使用 java.io.*它是为了实现一个计算器。 例如:第一行:1+2+3第二行:1+ 2*3(标记之间有空格) 进入表{
我有一个 ListView 控件来显示项目,我想提供一个滑动/滑动手势来选择一个项目。我用 GestureRecognizer类来识别交叉滑动手势,但我还想通过水平移动选择的项目来为这个手势设置动画。
我有一个导航栏,当单击菜单图标时,它将滑入“#secondary-nav”并隐藏“#primary-nav”。然而 jquery 似乎没有显示“#secondary-menu”。下面提供的是 HTMl
这个问题已经有答案了: how to make a sliding up panel like the Google Maps app? (2 个回答) 已关闭 7 年前。 我正在寻找类似的实现,如下
我有 ViewPager(Slide) 和 3 张图片。共有三个图像是通过 Internet 下载的。如果我将图片换到服务器上的另一台服务器上,链接保持不变,但应用程序中的图片没有改变,仍然是缓存中的
我在 gridview 中创建了两个按钮。 我想达到以下目的,但不知道应该用什么方法? 首先我触摸第一个按钮,将显示 toast 1 msg。通过将我的手指滑到第二个按钮而不抬起我的手指,将显示 to
所以我设置了一个小的 jquery 动画,用户将鼠标悬停在容器上一段时间,这会导致容器 split ,然后显示内部信息。 我不希望鼠标一进入容器就开始动画,所以我在动画上放了一个delay()。现在动
这个问题在这里已经有了答案: Simulate swipe with mouse in javascript (5 个答案) 关闭 7 年前。
我希望我的 Sprite 像在冰上一样滑动。因此,如果他在地面上,那么他可以正常行走,但当他接触冰时,他会滑动,直到有东西阻止他。有谁知道如何才能做到这一点?谢谢 最佳答案 像“Sprite Move
我的代码有几个问题:HTML: Bellevue
我正在尝试实现从 fragment1 过渡到 fragment2 的滑动动画。我正在使用 setCustomAnimations 方法。而且我知道我需要使用框架方法来替换 fragment 。 我的代
我不知道你们是否听说过 app chomp,但应用程序中有一个布局,如下图所示。我想知道他们是如何设置的,我将如何使用它来为我自己的应用程序制作类似的东西。有趣的是,当你滑动时,没有像水平 Scrol
我想检测用户何时在一个单元格占据整个屏幕宽度的 collectionView 中向左或向右滑动。是否可以不添加手势识别器。我试过添加手势识别器,但只有当我们将 collectionView 的 scr
我正在尝试开发一个应用程序来复制类似 tinder 的基于滑动的提要。该应用程序的想法与火种非常相似,也具有向右滑动和向左滑动匹配功能。 到目前为止我做了什么-我在 MongoDB 中创建了一个刷卡集
我是一名优秀的程序员,十分优秀!