欢迎光临,了解微信小程序开发,就上易用通!

微信小程序快速开发-食堂菜单案例

发布:2018-04-21 09:49浏览: 来源:网络 作者:cola

(1)这是目录结构。 

微信小程序快速开发-食堂菜单案例(图1)

(2)只写了一个index页面。

——这个页面的布局分为上下两部分。上面一部分是一个view,里面嵌套了3个view,用来切换tab的。

——下面是内容区域。用了小程序的swiper控件,swiper控件里面放置的是scroll-view控件。这里面设置的高度用的是百分比,这存在一定的问题。不如CSS3可以混用百分比和数值来的方便,虽然这种方式存在兼容性问题。

——index.wxml。

 

				
  1. <view class="recipe_tabs">
  2. <view class="recipe_tab {{currentTab==0 ? 'recipe_tab_active' : ''}}" data-current="0" bindtap="swipeContent">早餐</view>
  3. <view class="recipe_tab {{currentTab==1 ? 'recipe_tab_active' : ''}}" data-current="1" bindtap="swipeContent">午餐</view>
  4. <view class="recipe_tab {{currentTab==2 ? 'recipe_tab_active' : ''}}" data-current="2" bindtap="swipeContent">咖吧</view>
  5. </view>
  6.  
  7. <swiper current="{{currentTab}}" class="swiper_container" bindchange="swiperChange">
  8. <swiper-item>
  9. <scroll-view scroll-y style="height:100%">
  10. <view class="recipe_cell" wx:for="{{breakfests}}">
  11. <image class="recipe_img" src="{{item.RECIPE_IMG}}"></image>
  12. <view class="recipe_name">{{item.RECIPE_NAME}}</view>
  13. </view>
  14. </scroll-view>
  15. </swiper-item>
  16. <swiper-item>
  17. <scroll-view scroll-y style="height:100%">
  18. <view class="recipe_cell" wx:for="{{lunches}}">
  19. <image class="recipe_img" src="{{item.RECIPE_IMG}}"></image>
  20. <view class="recipe_name">{{item.RECIPE_NAME}}</view>
  21. </view>
  22. </scroll-view>
  23. </swiper-item>
  24. <swiper-item>
  25. <scroll-view scroll-y style="height:100%">
  26. <view class="recipe_cell" wx:for="{{desserts}}">
  27. <image class="recipe_img" src="{{item.RECIPE_IMG}}"></image>
  28. <view class="recipe_name">{{item.RECIPE_NAME}}</view>
  29. </view>
  30. </scroll-view>
  31. </swiper-item>
  32. </swiper>

(3)样式没什么好说的,index.wxss。

/index.wxss/

 

				
  1. page{
  2. background-color: #EEEEEE;
  3. height: 100%;
  4. }
  5.  
  6. /* recipe_tab */
  7. .recipe_tabs{
  8. background-color: #FFFFFF;
  9. height: 7%;
  10. }
  11. .recipe_tab{
  12. display: inline-block;





免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。