微信小程序之顶部导航栏(选项卡)实例 —— 微信小程序实战系列(1)

需求:顶部导航栏

效果图:



wxml



  {{item}}










wxss

page{
  display: flex;
  flex-direction: column;
  height: 100%;
}
.navbar{
  flex: none;
  display: flex;
  background: #fff;
}
.navbar .item{
  position: relative;
  flex: auto;
  text-align: center;
  line-height: 80rpx;
}
.navbar .item.active{
  color: #FFCC00;
}
.navbar .item.active:after{
  content: "";
  display: block;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4rpx;
  background: #FFCC00;
}

js

var app = getApp()
Page({
  data: {
    navbar: ['首页', '搜索', '我'],
    currentTab: 0
  },
  navbarTap: function(e){
    this.setData({
      currentTab: e.currentTarget.dataset.idx
    })
  }
})

运行:




更多小程序的教程


微信开发者工具的快捷键

微信小程序的文件结构 —— 微信小程序教程系列(1)

微信小程序的生命周期实例演示 —— 微信小程序教程系列(2)

微信小程序的动态修改视图层的数据 —— 微信小程序教程系列(3)

微信小程序的新建页面 —— 微信小程序教程系列(4)

微信小程序的如何使用全局属性 —— 微信小程序教程系列(5)

微信小程序的页面跳转 —— 微信小程序教程系列(6)

微信小程序标题栏和导航栏的设置 —— 微信小程序教程系列(7)

微信小程序的作用域和模块化 —— 微信小程序教程系列(8)

微信小程序视图层的数据绑定 —— 微信小程序教程系列(9)

微信小程序视图层的条件渲染 —— 微信小程序教程系列(10)

微信小程序视图层的列表渲染 —— 微信小程序教程系列(11)

微信小程序视图层的模板 —— 微信小程序教程系列(12)

微信小程序wxss的尺寸单位rpx —— 微信小程序教程系列(13)

微信小程序的网络请求 —— 微信小程序教程系列(14)

微信小程序的百度地图获取地理位置 —— 微信小程序教程系列(15)

微信小程序使用百度api获取天气信息 —— 微信小程序教程系列(16)

微信小程序获取系统日期和时间 —— 微信小程序教程系列(17)

微信小程序之顶部导航栏实例 —— 微信小程序实战系列(1)

微信小程序之上拉加载(分页加载)实例 —— 微信小程序实战系列(2)

微信小程序之轮播图实例 —— 微信小程序实战系列(3)

微信小程序之仿android fragment之可滑动的底部导航栏实例 —— 微信小程序实战系列(4)

微信小程序之登录页实例 —— 微信小程序实战系列(5)

微信小程序之自定义toast实例 —— 微信小程序实战系列(6)


更多小程序的教程请查看:http://blog.csdn.net/michael_ouyang/article/details/54700871

谢谢观看,不足之处,敬请指导

你可能感兴趣的:(微信小程序)