中国优质的IT技术网站
专业IT技术创作平台
IT职业在线教育平台
<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>
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; } }
.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; }
微信扫码分享
仅贴代码并不能帮助读者很好的理解内容哦。
楼主能搭配点讲解之类的么,会更通俗易懂一些(●'◡'●)
优点是简洁,缺点是有点儿太简洁~~ ^_^
谢谢张荣超老师点评,以后写的详细一点,多提意见!谢谢
好的,需要怎么来描述讲解?
具体需要怎么写容易理解?谢谢
仿造flutter写的鸿蒙底部导航栏 https://harmonyos.51cto.com/posts/6777
java版本的可以指导一下啊
仅贴代码并不能帮助读者很好的理解内容哦。
楼主能搭配点讲解之类的么,会更通俗易懂一些(●'◡'●)
优点是简洁,缺点是有点儿太简洁~~ ^_^
谢谢张荣超老师点评,以后写的详细一点,多提意见!谢谢
好的,需要怎么来描述讲解?
具体需要怎么写容易理解?谢谢
仿造flutter写的鸿蒙底部导航栏 https://harmonyos.51cto.com/posts/6777
java版本的可以指导一下啊