#2020征文-手机#鸿蒙js开发四:菜单栏和轮播图,列表布局

六合李欣
发布于 2021-1-15 16:54
浏览
1收藏

第六课 微信小程序的滚动分类导航布局和鸿蒙的List列表布局

#2020征文-手机#鸿蒙js开发四:菜单栏和轮播图,列表布局-鸿蒙开发者社区

                                                                                                         1.首页及轮播图

#2020征文-手机#鸿蒙js开发四:菜单栏和轮播图,列表布局-鸿蒙开发者社区

                                                                                                          2.选项卡

#2020征文-手机#鸿蒙js开发四:菜单栏和轮播图,列表布局-鸿蒙开发者社区

                                                                                                          3.列表

 

 

export default {
    data: {
        title: 'World',

        //定义菜单项
        menus:[{"text":"首页","img1":"./common/ones.png","img2":"./common/oneu.png"},
               {"text":"分类","img1":"./common/cs.png","img2":"./common/cu.png"},
               {"text":"内容","img1":"./common/cons.png","img2":"./common/conu.png"},
               {"text":"我的","img1":"./common/mys.png","img2":"./common/myu.png"}],

        //定义一个下标
        cindex:0,
        //标题:
        ptitle:"歌曲列表",
        //定义列表的数据
        lists:[{"img":"./common/a0.jpg","text":"歌曲1","price":"10元"},
               {"img":"./common/a1.jpg","text":"歌曲2","price":"10元"},
               {"img":"./common/a2.jpg","text":"歌曲3","price":"10元"},
               {"img":"./common/a3.jpg","text":"歌曲4","price":"10元"},
               {"img":"./common/a4.jpg","text":"歌曲5","price":"10元"},
               {"img":"./common/a5.jpg","text":"歌曲6","price":"10元"},
               {"img":"./common/a6.jpg","text":"歌曲7","price":"10元"},
               {"img":"./common/a7.jpg","text":"歌曲8","price":"10元"},
               {"img":"./common/a8.jpg","text":"歌曲9","price":"10元"},
               {"img":"./common/a9.jpg","text":"歌曲10","price":"10元"},
               {"img":"./common/a10.jpg","text":"歌曲11","price":"10元"},
               {"img":"./common/a11.jpg","text":"歌曲12","price":"10元"},
               {"img":"./common/a12.jpg","text":"歌曲13","price":"10元"},
               {"img":"./common/a13.jpg","text":"歌曲14","price":"10元"},
               {"img":"./common/a14.jpg","text":"歌曲15","price":"10元"},
               {"img":"./common/a15.jpg","text":"歌曲16","price":"10元"},
               {"img":"./common/a16.jpg","text":"歌曲17","price":"10元"},
               {"img":"./common/a17.jpg","text":"歌曲18","price":"10元"},
               {"img":"./common/a18.jpg","text":"歌曲19","price":"10元"},
               {"img":"./common/a19.jpg","text":"歌曲20","price":"10元"},
               {"img":"./common/a20.jpg","text":"歌曲21","price":"10元"},
               {"img":"./common/a21.jpg","text":"歌曲22","price":"10元"},
               {"img":"./common/a22.jpg","text":"歌曲23","price":"10元"},
               {"img":"./common/a23.jpg","text":"歌曲24","price":"10元"},
               {"img":"./common/a24.jpg","text":"歌曲25","price":"10元"},
               {"img":"./common/a25.jpg","text":"歌曲26","price":"10元"},
               {"img":"./common/a26.jpg","text":"歌曲27","price":"10元"},
               {"img":"./common/a27.jpg","text":"歌曲28","price":"10元"},
               {"img":"./common/a28.jpg","text":"歌曲29","price":"10元"},

        ]

    },
    changemenu(index)
    {
        console.log("当前的值为:"+index);
        //赋值
        this.cindex=index;

        //改变轮播图的具体哪项  和轮播图的index
        this.$element("sw").swipeTo({index:index});

    }

}
.firstview{
    width: 100%;
    height: 1200px;
    background-color: deepskyblue;
}

.bottommenuview{
    width: 100%;
    height: 160px;
    border-top:5px  solid   black;
    position: fixed;
    bottom: 0px;
    left: 0px;
    background-color: powderblue;
    display: flex;
    justify-content: space-around;
    
}
.cellmenu{
    width: 22%;
    height: 90%;
    /**border: 1px  solid  red;**/
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.imgview{
    width: 80%;
    height: 50%;
   /** border:2px solid  black;**/
    display: flex;
    justify-content: center;
    align-items: flex-end;

}
.txtview{
    width: 80%;
    height: 40%;
   /** border:2px solid  green;**/
    display: flex;
    justify-content: center;
    align-items: center;
}
.a{
    color: black;
    font-size: 25px;
    font-weight: bold;

}
.b{
    color: green;
    font-size: 25px;
    font-weight: bold;
}
.cimg{
    width: 40px;
    height: 40px;
}
.swiperview{
    width: 100%;
    height: 100%;
}
.box{
    width: 100%;
    height: 100%;

}
.one{
    background-color: palegreen;
    
}
.two{
    
    background-color: deepskyblue;
    
}
.three{
    
    background-color: cornflowerblue;
    display: flex;
    flex-direction: column;
    
}
.four{
    
    background-color: aqua;
    
}
.txt1{
    font-family:sans-serif;
    font-size: 60px;
    
}
.swtxt{
    width: 800px;
    height: 300px;

}
.switem{
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}
.one1{
    background-color: aqua;
}
.one2{
    background-color: cornflowerblue;
}
.one3{
    background-color: deepskyblue;
}
.onet1{
    font-size: 60px;
    color: snow;
    font-weight: bold;
}
.threadhead{
    width: 100%;
    height: 10%;
    border-bottom: 5px  solid  black;
    display: flex;
    justify-content: center;
}
.threecontent{
    width: 100%;
    height: 85%;
    background-color: snow;
}
.listview{
    width: 100%;
    height: 100%;
}
.lineview{
    width: 100%;
    height: 11%;
    border-bottom: 4px  solid  peru;
    display: flex;
    align-items: center;
    justify-content: space-around;
}
.imgview1{
    width: 30%;
    /**border:10px  solid  black ;**/
    height: 80px;

}
.img1{
    width: 60px;
    height: 100%;
    /**border:10px  solid  palegreen ;**/
}
.listtxt1{
    width: 30%;
   /** border:5px  solid  green ;**/
    height: 60px;
   text-align: center;
}
.cimg1{
    width: 60px;
    height: 60px;
}
.tabs{
    
    width: 100%;
    height: 100%;
}
.tab-bar{
    width: 100%;
    height: 60px;
    background-color: palegreen;
}
.tab-content{
    width: 100%;
    height: 100%;
}
.itemview{
    width: 100%;
    height: 100%;
}
.t1{
    background-color: peru;
}
.t2{
    background-color: cornflowerblue;
}
.t3{
    background-color: powderblue;
}

 

<div  class="firstview">
    <!-- 轮播布局 start -->
    <swiper class="swiperview"  id="sw"  index="0">
        <div  class="box one">
            <!--轮播图  start -->
            <swiper class="swtxt" autoplay="true"   duration="5000"  interval="3000" indicator="true" loop="true"  index="0">
               <div  class="switem one1">
                    <text class="onet1">第一幅轮播图</text>
               </div>
                <div  class="switem one2">
                    <text class="onet1">第二幅轮播图</text>
                </div>
                <div  class="switem one3">
                    <text class="onet1">第三幅轮播图</text>
                </div>
            </swiper>
            <!--轮播图  end -->
       </div>
        <div class="box two">
            <tabs  class="tabs"  index="0"  vertical="false">

                <tab-bar class="tab-bar" mode="fixed">
                    <text>推荐</text>
                    <text>头条</text>
                    <text>本地</text>
                </tab-bar>

                <tab-content class="tab-content"  scrollable="true">
                   <div class="itemview t1">
                        <text>推荐的内容区</text>
                   </div>
                    <div class="itemview t2">
                        <text>头条的内容区</text>
                    </div>
                    <div class="itemview t3">
                        <text>本地的内容区</text>
                    </div>
                </tab-content>
            </tabs>
        </div>
        <div class="box three">
            <div class="threadhead">
                <text>{{ptitle}}</text>
            </div>
            <div class="threecontent">
              <list  class="listview">
                 <list-item  class="lineview" for="{{lists}}">
                     <div class="imgview1">
                       <image  class="cimg1" src="{{$item.img}}"></image>
                     </div>
                      <text class="listtxt1">{{$item.text}}</text>
                     <text class="listtxt1">{{$item.price}}</text>
                 </list-item>
              </list>
            </div>
        </div>
        <div class="box four">
            <text class="txt1">第四幅</text>
        </div>
    </swiper>
    <!-- 轮播布局 end -->

    <!--底部菜单栏 鸿蒙必须嵌套到父的视图容器start-->
    <div  class="bottommenuview">
        <block  for="{{menus}}">
            <div  class="cellmenu"  onclick="changemenu({{$idx}})">
                <div class="imgview">
                    <image class="cimg"
                            src="{{cindex==$idx?$item.img1:$item.img2}}">
                    </image>
                </div>
                <div  class="txtview">
                  <text class="{{cindex==$idx?'a':'b'}}">{{$item.text}}</text>
                </div>
            </div>
        </block>
    </div>
    <!--底部菜单栏 鸿蒙必须嵌套到父的视图容器end-->

</div>


 

 

分类
标签
已于2021-1-20 16:10:07修改
2
收藏 1
回复
举报
回复
    相关推荐