开发者

微信小程序 navbar实例详解

开发者 https://www.devze.com 2022-11-30 15:06 出处:网络 作者: xiaochun365
这篇文章主要介绍了微信小程序 navbar实例详解的相关资料,需要的朋友可以参考下

微信小程序 navbar实例详解

实现效果图:

微信小程序 navbar实例详解

data

typeList: [ 
  { name: "日报", id: "1" }, 
  { name: "周报", id: "2" }, 
  { name: "月报", id: "3" }, 
  { name: "目录", id: "4" }] 

js

 that.setData({ 
  dateValue: util.formatTime(new Date()), //pic编程客栈ker date 
  typeList: appInstance.typeList, 
  currentTypeId: "1" 
 }) 
 
 
//添加点击模板点击事件 
for (var i = 0; i < appInstance.typeList.length; i++) { 
 (function (item) { 
  pageObject['bind' + item.id] = function (e) { 
   this.setData({ 
    currentTypeId: e.currentTarget.dataset.index 
   }) 
  } 
 编程客栈})(appInstance.typeList[i]) 
} 



wxml

<dl class="menu"> 
 <block wx:for="{{typeList}}" wx:for-item="type" wx:key="{{index}}" wx:for-index="{{index}}"> 
 <dt bindtap="bind{{type.id}}" data-index="{{type.id}}" class="{{currentTypeId==type.id?'yesCurrentType':'noCurrentType'}}">{{type.name}}</dt> 
 </block> 
</dl> 
<picker class="timePicker" mode="date" value="{{dateValue}}" bindchange="datePick编程客栈erBindchange" start="1999-01-01" end="2999-12-12">时间:{{dateValue}} 
 <image class="selReportImg" src="../images/clock.png"></image> 
</picker&ghttp://www.devze.comt; 

wxss

.timePicker { 
 width: 90%; 
 padding: 10rpx; 
 margin: auto编程客栈; 
 border: 1px solid red; 
} 
 
.menu { 
 display: flex; 
 flex-direction: row; 
 align-items: flex-start; 
 justify-content: space-between; 
} 
 
dt { 
 width: 25%; 
 height: 100rpx; 
} 
 
.noCurrentType { 
 height: 90rpx; 
 color: black; 
 padding-left: 30rpx; 
 border: 1px solid; 
 background-color: #c2c2c2; 
} 
开发者_Python学习 
.yesCurrentType { 
 color: black; 
 padding-left: 30rpx; 
} 

 感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号