- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章微信小程序实现滚动Tab选项卡由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
本文实例为大家分享了微信小程序实现滚动Tab选项卡的具体代码,供大家参考,具体内容如下 。
最终效果如上。问题:
1、tab标题总共8个,所以一屏无法全部显示。 2、tab内容区左右滑动切换时,tab标题随即做标记(active)。 3、当active的标题不在当前屏显示时,要使其能显示到当前屏中.
1、wxml结构 。
tab标题因一排八个,所以使用 scroll-view组件,使其可横向滚动。 tab内容可左右滑动切换,使用swiper组件实现 为了偷懒,所以数据都通过wx:for遍历重复出来.
说明:
1、设置data-current属性用于:点击当前项时,通过点击事件swichNav中处理e.dataset.current取到点击的目标值。 2、swiper组件的current组件用于控制当前显示哪一页 3、swiper组件绑定change事件switchTab,通过e.detail.current拿到当前页 。
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
|
<
view
>
<
scroll-view
scroll-x
=
"true"
class
=
"tab-h"
scroll-left
=
"{{scrollLeft}}"
>
<
view
class
=
"tab-item {{currentTab==0?'active':''}}"
data-current
=
"0"
bindtap
=
"swichNav"
>健康</
view
>
<
view
class
=
"tab-item {{currentTab==1?'active':''}}"
data-current
=
"1"
bindtap
=
"swichNav"
>情感</
view
>
<
view
class
=
"tab-item {{currentTab==2?'active':''}}"
data-current
=
"2"
bindtap
=
"swichNav"
>职场</
view
>
<
view
class
=
"tab-item {{currentTab==3?'active':''}}"
data-current
=
"3"
bindtap
=
"swichNav"
>育儿</
view
>
<
view
class
=
"tab-item {{currentTab==4?'active':''}}"
data-current
=
"4"
bindtap
=
"swichNav"
>纠纷</
view
>
<
view
class
=
"tab-item {{currentTab==5?'active':''}}"
data-current
=
"5"
bindtap
=
"swichNav"
>青葱</
view
>
<
view
class
=
"tab-item {{currentTab==6?'active':''}}"
data-current
=
"6"
bindtap
=
"swichNav"
>全部</
view
>
<
view
class
=
"tab-item {{currentTab==7?'active':''}}"
data-current
=
"7"
bindtap
=
"swichNav"
>其他</
view
>
</
scroll-view
>
<
swiper
class
=
"tab-content"
current
=
"{{currentTab}}"
duration
=
"300"
bindchange
=
"switchTab"
style
=
"height:{{winHeight}}rpx"
>
<
swiper-item
wx:for
=
"{{[0,1,2,3,4,5,6,7]}}"
>
<
scroll-view
scroll-y
=
"true"
class
=
"scoll-h"
>
<
block
wx:for
=
"{{[1,2,3,4,5,6,7,8]}}"
wx:key
=
"*this"
>
<
view
class
=
"item-ans"
>
<
view
class
=
"avatar"
>
<
image
class
=
"img"
src
=
"/avatar.png"
></
image
>
</
view
>
<
view
class
=
"expertInfo"
>
<
view
class
=
"name"
>欢颜</
view
>
<
view
class
=
"tag"
>知名情感博主</
view
>
<
view
class
=
"answerHistory"
>134个回答,2234人听过 </
view
>
</
view
>
<
navigator
url
=
"/pages/askExpert/expertDetail"
class
=
"askBtn"
>问TA</
navigator
>
</
view
>
</
block
>
</
scroll-view
>
</
swiper-item
>
</
swiper
>
</
view
>
|
2、js部分 。
微信小程序在开发起来,个人感觉挺像vue的,以数据驱动视图的更新。所以在小程序中,不能直接操作dom,当然也不能使用jquery之类的库.
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
|
var
app = getApp();
Page({
data:{
winHeight:
""
,
//窗口高度
currentTab:0,
//预设当前项的值
scrollLeft:0,
//tab标题的滚动条位置
expertList:[{
//假数据
img:
"avatar.png"
,
name:
"欢顔"
,
tag:
"知名情感博主"
,
answer:134,
listen:2234
}]
},
// 滚动切换标签样式
switchTab:
function
(e){
this
.setData({
currentTab:e.detail.current
});
this
.checkCor();
},
// 点击标题切换当前页时改变样式
swichNav:
function
(e){
var
cur=e.target.dataset.current;
if
(
this
.data.currentTaB==cur){
return
false
;}
else
{
this
.setData({
currentTab:cur
})
}
},
//判断当前滚动超过一屏时,设置tab标题滚动条。
checkCor:
function
(){
if
(
this
.data.currentTab>4){
this
.setData({
scrollLeft:300
})
}
else
{
this
.setData({
scrollLeft:0
})
}
},
onLoad:
function
() {
var
that =
this
;
// 高度自适应
wx.getSystemInfo( {
success:
function
( res ) {
var
clientHeight=res.windowHeight,
clientWidth=res.windowWidth,
rpxR=750/clientWidth;
var
calc=clientHeight*rpxR-180;
console.log(calc)
that.setData( {
winHeight: calc
});
}
});
},
footerTap:app.footerTap
})
|
3、wxss样式 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
.tab-h{
height
:
80
rpx;
width
:
100%
; box-sizing: border-box;
overflow
:
hidden
;
line-height
:
80
rpx;
background
:
#F7F7F7
;
font-size
:
16px
;
white-space
:
nowrap
;
position
:
fixed
;
top
:
0
;
left
:
0
;
z-index
:
99
;}
.tab-item{
margin
:
0
36
rpx;
display
: inline-
block
;}
.tab-item.active{
color
:
#4675F9
;
position
:
relative
;}
.tab-item.active:after{
content
:
""
;
display
:
block
;
height
:
8
rpx;
width
:
52
rpx;
background
:
#4675F9
;
position
:
absolute
;
bottom
:
0
;
left
:
5
rpx;border-radius:
16
rpx;}
.item-ans{
width
:
100%
;
display
: flex; flex-grow: row no-wrap;justify-
content
: space-between;
padding
:
30
rpx;box-sizing: border-box;
height
:
180
rpx;align-items:
center
;
border-bottom
:
1px
solid
#F2F2F2
;}
.avatar{
width
:
100
rpx;
height
:
100
rpx;
position
:
relative
;
padding-right
:
30
rpx;}
.avatar .img{
width
:
100%
;
height
:
100%
;}
.avatar .doyen{
width
:
40
rpx;
height
:
40
rpx;
position
:
absolute
;
bottom
:
-2px
;
right
:
20
rpx;}
.expertInfo{
font-size
:
12px
;flex-grow:
2
;
color
:
#B0B0B0
;
line-height
:
1.5em
;}
.expertInfo .name{
font-size
:
16px
;
color
:
#000
;
margin-bottom
:
6px
;}
.askBtn{
width
:
120
rpx;
height
:
60
rpx;
line-height
:
60
rpx;
text-align
:
center
;
font-size
:
14px
; border-radius:
60
rpx;
border
:
1px
solid
#4675F9
;
color
:
#4675F9
;}
.tab-content{
margin-top
:
80
rpx;}
.scoll-h{
height
:
100%
;}
|
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我.
原文链接:https://blog.csdn.net/Sophie_U/article/details/71745125 。
最后此篇关于微信小程序实现滚动Tab选项卡的文章就讲到这里了,如果你想了解更多关于微信小程序实现滚动Tab选项卡的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
在 Android 的 API > 19 中是否有任何方法可以获取可移动 SD 卡的路径? 与外部 SD 卡一样,我们有 Environment.getExternalStorageDirectory
一些 Android 设备有 microSD(或其他存储卡)插槽,通常安装为 /storage/sdcard1 据我所知,自 Android 4.4 起 Google 限制了对此内存的访问,并在 An
我使用 Java Card 2.1.2 SDK 和 GPShell 作为与设备通信的方式在 Java Card 上构建一个项目。我从 GpShell 测试了 helloworld 示例,并成功发送了
我开发了一个应用程序,它有一个来电接收器,它适用于所有手机。一位用户有一部双 SIM 卡安卓手机。该应用程序适用于第一张 SIM 卡。但是当有人调用他的第二张 SIM 卡时,我们的应用程序不会被调用。
我有一个带预览的文件输入。 这是笔 Codepen 我想强制高度,我无法理解我该怎么做。我想将此组件的高度固定为 300px(示例),我还需要保持加载图像的正确纵横比,用灰色背景填充空白。现在我保持宽
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 6年前关闭。 Improve this qu
我正在使用此代码访问 SD card : import os from os.path import join from jnius import autoclass #from android.pe
我正在为数据记录设备编写固件。它以 20 Hz 的频率从传感器读取数据并将数据写入 SD 卡。但是,向SD卡写入数据的时间并不一致(大约200-300 ms)。因此,一种解决方案是以一致的速率将数据写
我正在使用以下代码将视频放到网站上,但是在垂直方向上,手机屏幕上只能看到视频的左半部分 我不是网络开发人员。有人可以告诉我确切的内容吗,如何使其正确放置在手机屏幕上? 是在youtube iframe
我正在使用 Vuetify 1.5 和 Vuetify 网格系统来设置我的布局。现在我有一个组件 HelloWorld我将其导入到我的 Parent 中成分。我已经在我的 HelloWorld 中设置
我使用 python 制作了一个简单的二十一点游戏。我制作了游戏的其余部分,但我正在努力放入 ASCII 卡,所以这只是代码的一小部分。我尝试将 * len(phand) 放在附加行的末尾。虽然这确实
我正在使用玩家卡设置 Twitter 卡。它可以在预览工具中运行,但文档说它需要在“twitter.com 现代桌面浏览器? native iOs 和 Android Twitter 应用程序?mob
任何旧的 GSM 兼容 SIM 卡(3G USIM 的奖励)。 我想我需要一些硬件?谁能为业余爱好者推荐一些便宜的东西,以及一些更专业的东西? 我认为会有一个带有硬件的 API 的完整文档,所以也许这
我使用 python 制作了一个简单的二十一点游戏。我制作了游戏的其余部分,但我正在努力放入 ASCII 卡,所以这只是代码的一小部分。我尝试将 * len(phand) 放在附加行的末尾。虽然这确实
我记得前一段时间读到有 cpu 卡供系统添加额外的处理能力来进行大规模并行化。任何人都有这方面的经验和任何资源来研究项目的硬件和软件方面吗?这项技术是否不如传统集群?它更注重功率吗? 最佳答案 有两个
我检查外部存储是否已安装并且可用于读/写,然后从中读取。我使用的是确切的官方 Android 示例代码 ( from here )。 它说外部存储未安装。 getExternalFilesDir(nu
在 Android 2.1 及更低版本中,Android 应用程序可以请求下载到 SD 卡上吗?另外我想知道应用程序是否可以请求一些包含视频的文件夹下载到 SD 卡上?以及如何做到这一点? 提前致谢。
我们编写了一个 Windows 设备驱动程序来访问我们的自定义 PCI 卡。驱动程序使用 CreateFile 获取卡的句柄。 我们最近在一次安装中遇到了问题,卡似乎停止工作了。我们尝试更换卡(更换似
有些新设备(例如 Samsung Galaxy)带有两个 SD 卡。我想知道是否有任何方法可以确定设备是否有两张 SD 卡或一张 SD 卡。谢谢 最佳答案 我认为唯一的方法是使用 检查可用根的列表 F
我正在尝试将文件读/写到 SD 卡。我已经尝试在我的真实手机和 Eclipse 中的模拟器上执行此操作。在这两种设备上,对/mnt/sdcard/或/sdcard 的权限仅为“d--------”,我
我是一名优秀的程序员,十分优秀!