您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
微信小程序制作横向滚动导航
发布时间:2018-03-13 13:26:38编辑:雪饮阅读()
index.wxml
<scroll-view class="scroll-view_H" scroll-x="true">
<text wx:for="{{section}}" wx:key="id" id="{{item.id}}" catchtap="handleTap" class="nav {{item.id == currentId ? 'nav-hover' : ''}}">
{{item.name}}
</text>
</scroll-view>
index.wxss
/* 头部滑动导航 */
.scroll-view_H{white-space:nowrap;width: 100%;padding:6px 40px 0;box-sizing: border-box;}
.nav{display:inline-block;font-size:16px;color: #2b2e33;border-bottom: 2px solid transparent;padding:10px;}
.nav-hover{color: #349393;}
index.js
Page({
data: {
section: [
{ name: '精选', id: '1001' }, { name: '黄金单身汉', id: '1032' },
{ name: '综艺', id: '1003' }, { name: '电视剧', id: '1004' },
{ name: '电影', id: '1005' }, { name: '少儿', id: '1021' }
],
currentId:1001,
},
})
关键字词:微信,小程序,横向,滚动,导航