#2020征文-手机#鸿蒙js开发二:鸿蒙js底部菜单栏和三元运算

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

#2020征文-手机#鸿蒙js开发二:鸿蒙js底部菜单栏和三元运算-鸿蒙开发者社区

<div  class="firstview">

    <!--底部菜单栏 鸿蒙必须嵌套到父的视图容器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>
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
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

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

    }

}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
.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;
}
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.

 

#2020征文-手机#鸿蒙js开发二:鸿蒙js底部菜单栏和三元运算-鸿蒙开发者社区

 

 

 

 

分类
标签
已于2021-1-20 15:56:01修改
5
收藏 1
回复
举报
5
7
1
7条回复
按时间正序
/
按时间倒序
Whyalone
Whyalone

仅贴代码并不能帮助读者很好的理解内容哦。

回复
2021-1-14 10:32:42
jordana
jordana

楼主能搭配点讲解之类的么,会更通俗易懂一些(●'◡'●)

回复
2021-1-14 17:23:38
张荣超_九丘教育
张荣超_九丘教育

优点是简洁,缺点是有点儿太简洁~~ ^_^

回复
2021-1-14 22:17:56
六合李欣
六合李欣 回复了 张荣超_九丘教育
优点是简洁,缺点是有点儿太简洁~~ ^_^

谢谢张荣超老师点评,以后写的详细一点,多提意见!谢谢

回复
2021-1-14 22:39:48
六合李欣
六合李欣 回复了 jordana
楼主能搭配点讲解之类的么,会更通俗易懂一些(●'◡'●)

好的,需要怎么来描述讲解?

回复
2021-1-14 22:40:10
六合李欣
六合李欣 回复了 Whyalone
仅贴代码并不能帮助读者很好的理解内容哦。

具体需要怎么写容易理解?谢谢

回复
2021-1-14 22:40:31
BLUESKYHOST
BLUESKYHOST

仿造flutter写的鸿蒙底部导航栏 https://harmonyos.51cto.com/posts/6777

java版本的可以指导一下啊

回复
2021-7-13 16:33:35


回复
    相关推荐