鸿蒙js开发7鸿蒙分组列表和弹出Menu菜单

想了解更多内容,请访问:

和华为官方合作共建的鸿蒙技术社区

https://harmonyos./#zz

任正非:现在华为必须全面靠自己打造产品,要敢于将鸿蒙推入竞争,星光不问赶路人,时光不负有心人。

1.鸿蒙视图效果

点击menu菜单一项,跳转页面,底部菜单栏和轮播布局和轮播图

2.js业务数据和事件

 
 
 
 
  1. import prompt from '@system.prompt';
  2. import router from '@system.router';
  3. export default {
  4.     data: {
  5.         title: 'World',
  6.         fundatas:[{"fathermenu":"员工管理","childmenu":[{"icon":"/common/emp.png","text":"查询员工"},{"icon":"/common/emp.png","text":"添加员工"},{"icon":"/common/emp.png","text":"删除员工"},{"icon":"/common/emp.png","text":"更新员工"}]},
  7.                   {"fathermenu":"客户服务","childmenu":[{"icon":"/common/customer.png","text":"一卡通兑"},{"icon":"/common/customer.png","text":"银联服务"},{"icon":"/common/customer.png","text":"票据业务"}]},
  8.                   {"fathermenu":"内部管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]},
  9.                   {"fathermenu":"合同管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]},
  10.                   {"fathermenu":"资产管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]},
  11.                   {"fathermenu":"绩效管理","childmenu":[{"icon":"","text":""},{"icon":"","text":""},{"icon":"","text":""}]},
  12.         ]
  13.     },
  14.     clickitem(itemvalue)
  15.     {
  16.         if(itemvalue=="查询员工")
  17.         {
  18.             this.$element("menu").show({
  19.                 x: 360,
  20.                 y: 120
  21.             });
  22.             //this.$element("menu").show();
  23.         }
  24.         prompt.showToast({
  25.             message:"点击了菜单"+itemvalue
  26.         })
  27.     },
  28.     menuSelected(e) {
  29.         prompt.showToast({
  30.             message:"你选择查询的值是:"+e.value
  31.         })
  32.         router.push({
  33.             uri:"pages/index/index"
  34.         })
  35.     }
  36. }

 3.页面视图代码

  
 
 
 
  1.     
  2.     
  3.        
  4.            
  5.                
  6.                    {{$item.fathermenu}}
  7.                
  8.                
  9.                  
  10.                     
  11.                     {{value.text}}
  12.                  
  13.                
  14.            
  15.        
  16.        
  17.     
  18.     
  19.     
  20.     
  21.         
  22.             男性员工
  23.         
  24.         
  25.             女性员工
  26.         
  27.     

 4.样式代码

 
 
 
 
  1. .container {
  2.     width: 100%;
  3.     height: 1200px;
  4. }
  5. .listview{
  6.     width: 100%;
  7.     height: 100%;
  8. }
  9. .groupview{
  10.     width: 100%;
  11.     height: 46%;
  12.     border-bottom: 5px solid  #DCDCDC;
  13. }
  14. .listitem{
  15.     width: 100%;
  16.     height: 20%;
  17.     display: flex;
  18.     justify-content: space-around;
  19. }
  20. .listitemone {
  21.     width: 50%;
  22.     height: 6%;
  23.     border-bottom: 1px  solid  #DCDCDC;
  24.     display: flex;
  25.     justify-content: space-around;
  26. }
  27. .cimg{
  28.     width: 40px;
  29.     height: 40px;
  30. }
  31. .tv1{
  32.     font-size: 35px;
  33.     font-weight: bold;
  34.     font-family: sans-serif;
  35.     letter-spacing: 10px;
  36. }
  37. .tv2{
  38.     font-size: 34px;
  39.     font-weight: bold;
  40.     font-family: sans-serif;
  41. }

 5.跳转页面后的视图层

    
 
 
 
  1.     
  2.         
  3.             
  4.                 
  5.                     
  6.                 
  •                 
  •                     
  •                 
  •                 
  •                     
  •                 
  •             
  •             
  •                      
  •                        1.鸿蒙
  •                      
  •                      
  •                          2.苹果
  •                      
  •                      
  •                          3.安卓
  •                      
  •             
  •         
  •         
  •             
  •                 
  •                     {{$item.title}}
  •                     {{$item.date}}
  •                 
  •             
  •         
  •         
  •             
  •                 
  •                     推荐
  •                     视频
  •                     本地
  •                     内容
  •                 
  •                 
  •                     
  •                         
  •                                 {{weatherInfo.city}}
  •                                  
  •                                     {{winfo.info}}
  •                                      {{winfo.direct}}
  •                                      {{winfo.power}}
  •                                  
  •                         
  •                         
  •                         
  •                     
  •                     
  •                         第二个
  •                     
  •                     
  •                         第三个
  •                     
  •                     
  •                         第四个
  •                     
  •                 
  •             
  •         
  •         
  •             第四幅
  •         
  •     
  •     
  •         
  •             
  •            {{$item.menu}}
  •         
  •     
  •  6.js业务逻辑部分

     
     
     
     
    1. import   fetch  from '@system.fetch';
    2. export default {
    3.     data: {
    4.         weatherInfo:{},
    5.         winfo:{},
    6.         nextInfo:[],
    7.         currentdata:0,
    8.         title: "",
    9.         menus:[{menu:"首页","path":"./common/ones.png","path1":"./common/oneu.png"},
    10.                {menu:"分类","path":"./common/cs.png","path1":"./common/cu.png"},
    11.                {menu:"内容","path":"./common/cons.png","path1":"./common/conu.png"},
    12.                {menu:"我的","path":"./common/mys.png","path1":"./common/myu.png"}],
    13.        todolist: [{
    14.       title: '刷leetcode',
    15.       date: '2020-06-25 10:00:00',
    16.     }, {
    17.       title: '看电影',
    18.       date: '2020-06-27 20:00:00',
    19.     },
    20.                   {
    21.                       title: '刷leetcode',
    22.                       date: '2020-06-25 10:00:00',
    23.                   }, {
    24.                       title: '看电影',
    25.                       date: '2020-06-27 20:00:00',
    26.                   },{
    27.                       title: '刷leetcode',
    28.                       date: '2020-06-25 10:00:00',
    29.                   }, {
    30.                       title: '看电影',
    31.                       date: '2020-06-27 20:00:00',
    32.                   },{
    33.                       title: '刷leetcode',
    34.                       date: '2020-06-25 10:00:00',
    35.                   }, {
    36.                       title: '看电影',
    37.                       date: '2020-06-27 20:00:00',
    38.                   },
    39.                   {
    40.                       title: '刷leetcode',
    41.                       date: '2020-06-25 10:00:00',
    42.                   }, {
    43.                       title: '看电影',
    44.                       date: '2020-06-27 20:00:00',
    45.                   },
    46.                   {
    47.                       title: '刷leetcode',
    48.                       date: '2020-06-25 10:00:00',
    49.                   }, {
    50.                       title: '看电影',
    51.                       date: '2020-06-27 20:00:00',
    52.                   },{
    53.                       title: '刷leetcode',
    54.                       date: '2020-06-25 10:00:00',
    55.                   }, {
    56.                       title: '看电影',
    57.                       date: '2020-06-27 20:00:00',
    58.                   },{
    59.                       title: '刷leetcode',
    60.                       date: '2020-06-25 10:00:00',
    61.                   }, {
    62.                       title: '看电影',
    63.                       date: '2020-06-27 20:00:00',
    64.                   },{
    65.                       title: '刷leetcode',
    66.                       date: '2020-06-25 10:00:00',
    67.                   }, {
    68.                       title: '看电影',
    69.                       date: '2020-06-27 20:00:00',
    70.                   },
    71.                   {
    72.                       title: '刷leetcode',
    73.                       date: '2020-06-25 10:00:00',
    74.                   }, {
    75.                       title: '看电影',
    76.                       date: '2020-06-27 20:00:00',
    77.                   },{
    78.                       title: '刷leetcode',
    79.                       date: '2020-06-25 10:00:00',
    80.                   }, {
    81.                       title: '看电影',
    82.                       date: '2020-06-27 20:00:00',
    83.                   },{
    84.                       title: '刷leetcode',
    85.                       date: '2020-06-25 10:00:00',
    86.                   }, {
    87.                       title: '看电影',
    88.                       date: '2020-06-27 20:00:00',
    89.                   }
    90.        ]
    91.     },
    92.     onInit() {
    93.        // this.title = this.$t('strings.world');
    94.         let  that  =this;
    95.         fetch.fetch({
    96.             url:"http://apis.juhe.cn/simpleWeather/query?city=南京&key=3dc98f3428c44424088015738a070554",
    97.             responseType:"json",
    98.             success:function(resp)
    99.             {
    100.                 let  currentValue=JSON.parse(resp.data);
    101.                 that.weatherInfo=currentValue.result;
    102.                 that.winfo=currentValue.result.realtime;
    103.                // that.nextInfo=currentValue.future;
    104.             }
    105.         })
    106.     },
    107.     changemenu(index)
    108.     {
    109.         this.currentdata=index;
    110.         this.$element('swiper').swipeTo({index: index});
    111.     }
    112. }

     7.样式代码

     
     
     
     
    1. .pageview{
    2.     width: 100%;
    3.     height: 1600px;
    4.     background-color: azure;
    5. }
    6. .bottommenu{
    7.     width: 100%;
    8.     height: 140px;
    9.     background-color: snow;
    10.     border-top: 10px  solid  black;
    11.     z-index:999;
    12.     position: fixed;
    13.     left: 0px;
    14.     bottom: 0px;
    15.     display: flex;
    16.     justify-content: center;
    17.     align-items: center;
    18. }
    19. .menubox{
    20.     width: 22%;
    21.     height: 90%;
    22.     /**border:9px  solid  #ccff6a;**/
    23.     margin-left: 20px;
    24.     display: flex;
    25.     flex-direction: column;
    26.     justify-content: center;
    27.     align-items: center;
    28. }
    29. .menutitle{
    30.     color: black;
    31.     font-weight: bold;
    32.     letter-spacing: 4px;
    33. }
    34. .cimg{
    35.     width: 40px;
    36.     height: 40px;
    37. }
    38. .swiperview{
    39.     width: 100%;
    40.     height: 100%;
    41. }
    42. .sw1{
    43.     width: 100%;
    44.     height: 100%;
    45.     display: flex;
    46.     flex-direction: column;
    47. }
    48. .sw2{
    49.     width: 100%;
    50.     height: 100%;
    51.     background-color: cornflowerblue;
    52. }
    53. .sw3{
    54.     width: 100%;
    55.     height: 100%;
    56.     background-color: #ccff6a;
    57. }
    58. .sw4{
    59.     width: 100%;
    60.     height: 100%;
    61.     background-color: #009865;
    62. }
    63. .swiper1 {
    64.     width: 100%;
    65.     height: 330px;
    66.     border: 1px solid #000000;
    67.     indicator-color: #cf2411;
    68.     indicator-size: 14px;
    69.     indicator-bottom: 20px;
    70.     indicator-right: 30px;
    71.     margin-top: 100px;
    72. }
    73. .swiperContent1 {
    74.     width: 800px;
    75.     height: 100%;
    76.     justify-content: center;
    77. }
    78. .button {
    79.     width: 70%;
    80.     margin: 10px;
    81. }
    82. .text {
    83.     font-size: 40px;
    84. }
    85. .swiper2{
    86.     width: 100%;
    87.     height: 100px;
    88.     background-color: powderblue;
    89. }
    90. .lineview{
    91.     width: 100%;
    92.     height: 100%;
    93. }
    94. .todo-wraper {
    95.     width: 100%;
    96.     height: 100%;
    97. }
    98. .todo-item {
    99.     width: 100%;
    100.     height: 80px;
    101.     flex-direction: row;
    102.     display: flex;
    103. }
    104. .todo-title {
    105.     width: 454px;
    106.     height: 40px;
    107.     text-align: center;
    108. }
    109. .tabs {
    110.     width: 100%;
    111. }
    112. .tab-bar {
    113.     margin: 10px;
    114.     height: 60px;
    115.     border-color: #007dff;
    116.     border-width: 1px;
    117. }
    118. .tab-text {
    119.     width: 300px;
    120.     text-align: center;
    121. }
    122. .tabcontent {
    123.     width: 100%;
    124.     height: 80%;
    125.     justify-content: center;
    126. }
    127. .item-content {
    128.     height: 100%;
    129.     justify-content: center;
    130.     display: flex;
    131.     flex-direction: column;
    132. }
    133. .item-title {
    134.     font-size: 60px;
    135. }
    136. .currentview{
    137.     width: 100%;
    138.     height: 30%;
    139.     border-bottom: 4px  solid  peru;
    140.     display: flex;
    141. }
    142. .nextview{
    143.     width: 100%;
    144.     height: 70%;
    145. }
    146. .leftview{
    147.     width: 30%;
    148.     height: 100%;
    149.     border-right 本文名称:鸿蒙js开发7鸿蒙分组列表和弹出Menu菜单
      当前路径:http://www.shufengxianlan.com/qtweb/news5/465805.html

      网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等

      广告

      声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联