自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

鴻蒙JS開(kāi)發(fā)6 鴻蒙的提示框、對(duì)話框和提示菜單的應(yīng)用

開(kāi)發(fā) 前端
本文主要描述對(duì)鴻蒙幻燈片組件、跑馬燈組件、提示框、提示菜單、頁(yè)面跳轉(zhuǎn)以及對(duì)話框的應(yīng)用

[[379017]]

想了解更多內(nèi)容,請(qǐng)?jiān)L問(wèn):

51CTO和華為官方戰(zhàn)略合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos.51cto.com/#zz

本文主要描述對(duì)鴻蒙幻燈片組件、跑馬燈組件、提示框、提示菜單、頁(yè)面跳轉(zhuǎn)以及對(duì)話框的應(yīng)用

幻燈片組件:<image-animator>

視圖及樣式:

  1. <div class="container"
  2.     <div class="c1"
  3.         <!--幻燈片組件--> 
  4.         <image-animator class="image-animator" duration="10s" fixedsize="false" images="{{imagesDatas}}"
  5.         </image-animator> 
  6.     </div> 
  7. </div> 

  1. .container { 
  2.     width: 100%; 
  3.     height: 1500px; 
  4.     display: flex; 
  5.     flex-direction: column
  6. .c1{ 
  7.     width: 100%; 
  8.     height: 35%; 
  9. .image-animator{ 
  10.     width: 100%; 
  11.     height: 100%; 

 業(yè)務(wù)邏輯層通過(guò)fetch請(qǐng)求向nginx反向代理服務(wù)請(qǐng)求所需數(shù)據(jù)

  1. import fetch from '@system.fetch'
  2.  
  3. export default { 
  4.     data: { 
  5.         imagesDatas:[] 
  6.         
  7.     }, 
  8.  
  9.     onInit(){ 
  10.         fetch.fetch({ 
  11.             //url對(duì)應(yīng)的地址為通過(guò)內(nèi)網(wǎng)穿透工具natapp映射出的nginx反向代理服務(wù)的地址 
  12.             url:'http://ibk3v7.natappfree.cc/text/images0.json'
  13.             responseType:"json"
  14.             success:(resp)=>{ 
  15.                 let datas = JSON.parse(resp.data); 
  16.                 this.imagesDatas = datas.imagedatas; 
  17.  
  18.             } 
  19.         }); 
  20.     } 

 images0.json文件中定義的數(shù)據(jù):


效果圖(圖片是可以自動(dòng)播放的):


跑馬燈組件:<marquee>

  1. <div class="container"
  2.     <marquee>金牛辭舊歲,萬(wàn)里賀新春。讓快樂(lè)與你同行,讓健康與你相伴,將美好與團(tuán)圓滿滿托付于你</marquee> 
  3. </div> 

 效果圖:


鴻蒙的彈出菜單、提示框、頁(yè)面跳轉(zhuǎn)的應(yīng)用

視圖和樣式:

  1. <div class="container"
  2.     <div class="c1"
  3.         <!--幻燈片組件--> 
  4. <!--        <image-animator class="image-animator" duration="10s" fixedsize="false" images="{{imagesDatas}}">--> 
  5. <!--        </image-animator>--> 
  6.     </div> 
  7.     <div class="c2"
  8.         <button onclick="clickbutton">我是個(gè)點(diǎn)擊按鈕</button> 
  9.     </div> 
  10.     <!--彈出菜單--> 
  11.     <menu id="menuid" onselected="selectmenu"
  12.         <option value="aaa">aaa</option
  13.         <option value="bbb">bbb</option
  14.         <option value="ccc">ccc</option
  15.     </menu> 
  16.  
  17. </div> 

  1. .container { 
  2.     width: 100%; 
  3.     height: 1500px; 
  4.     display: flex; 
  5.     flex-direction: column
  6. .c1{ 
  7.     width: 100%; 
  8.     height: 35%; 
  9. .c2{ 
  10.     width: 100%; 
  11.     height: 8%; 

 業(yè)務(wù)邏輯層:

  1. import prompt from '@system.prompt'
  2. import router from '@system.router'
  3. export default { 
  4.     data: { 
  5.     }, 
  6.  
  7.     //點(diǎn)擊按鈕觸發(fā) 彈出顯示菜單 事件 
  8.     clickbutton(){ 
  9.         //顯示id為 menuid 的菜單,此菜單出現(xiàn)位置默認(rèn)為屏幕左上角原點(diǎn),可通過(guò)在show()中添加坐標(biāo)來(lái)改變 
  10.         //this.$element("menuid").show(); 
  11.  
  12.         this.$element("menuid").show({ 
  13.             x:100, 
  14.             y:550 
  15.         }); 
  16.  
  17.     }, 
  18.     //選中彈出菜單中的項(xiàng)觸發(fā)事件 
  19.     selectmenu(e){ 
  20.         let path = e.value; 
  21.         //鴻蒙的提示框 
  22.         prompt.showToast({ 
  23.             message:path 
  24.         }); 
  25.  
  26.         if(path=="aaa"){ 
  27.             //鴻蒙提供的頁(yè)面跳轉(zhuǎn) 
  28.             router.push({ 
  29.                 uri:'pages/aaa/aaa' 
  30.             }); 
  31.  
  32.         }else if(path=="bbb"){ 
  33.             router.push({ 
  34.                uri:'pages/bbb/bbb' 
  35.             }); 
  36.         }else if(path=="ccc"){ 
  37.             router.push({ 
  38.                uri:'pages/ccc/ccc' 
  39.             }); 
  40.         } 
  41.     } 

 效果圖(點(diǎn)擊按鈕彈出菜單后點(diǎn)擊對(duì)應(yīng)菜單觸發(fā)跳轉(zhuǎn)頁(yè)面的事件):


鴻蒙的對(duì)話框

視圖和樣式:

  1. <div class="container"
  2.     <button onclick="onclick">我是另一個(gè)點(diǎn)擊按鈕</button> 
  3. </div> 

 邏輯層:

  1. import prompt from '@system.prompt'
  2. export default { 
  3.     data: { 
  4.  
  5.     }, 
  6.     onclick(){ 
  7.         //鴻蒙的對(duì)話框 
  8.         prompt.showDialog({ 
  9.             title:"對(duì)話框"
  10.             message:"確定刪除這條消息么?"
  11.             buttons:[{"text":"確定","color":"#00E5EE"}, 
  12.                      {"text":"取消","color":"#00E5EE"}], 
  13.             success:function(e){ 
  14.                 if(e.index==0){ 
  15.                     //鴻蒙的提示框 
  16.                     prompt.showToast({ 
  17.                         message:"您點(diǎn)擊了確定" 
  18.                     }); 
  19.                 }else if(e.index==1){ 
  20.                     prompt.showToast({ 
  21.                         message:"您點(diǎn)擊了取消" 
  22.                     }); 
  23.                 } 
  24.             } 
  25.         }); 
  26.     } 

 效果圖:

 

©著作權(quán)歸作者和HarmonyOS技術(shù)社區(qū)共同所有,如需轉(zhuǎn)載,請(qǐng)注明出處,否則將追究法律責(zé)任。

想了解更多內(nèi)容,請(qǐng)?jiān)L問(wèn):

51CTO和華為官方戰(zhàn)略合作共建的鴻蒙技術(shù)社區(qū)

https://harmonyos.51cto.com/#zz

 

責(zé)任編輯:jianghua 來(lái)源: 鴻蒙社區(qū)
相關(guān)推薦

2021-01-29 09:48:17

鴻蒙HarmonyOS應(yīng)用開(kāi)發(fā)

2011-07-01 11:33:00

Qt 模態(tài) 非模態(tài)

2012-12-03 10:47:54

WebJQuery控件

2015-10-29 11:13:23

iOS9使用框

2024-07-21 15:33:02

2011-07-21 15:50:42

jQuery Mobi頁(yè)面對(duì)話框

2011-11-23 09:47:36

Winform

2021-04-06 20:57:31

JavaScript彈出框窗口

2011-07-22 15:32:53

iPhone 按鈕 對(duì)話框

2009-12-28 13:47:35

WPF對(duì)話框

2009-12-28 14:32:31

WPF窗體對(duì)話框

2009-12-11 15:35:50

PHP彈出對(duì)話框

2010-01-28 16:55:26

Android對(duì)話框

2021-07-11 07:34:23

Windows 11操作系統(tǒng)微軟

2010-01-11 09:33:32

VB.NET對(duì)話框調(diào)用

2009-12-29 15:24:48

WPF對(duì)話框

2011-05-20 16:49:21

VB.NET

2009-11-03 09:21:26

Visual Stud

2019-01-09 11:30:07

Windows10空白對(duì)話框命令

2010-01-13 18:22:55

VB.NET對(duì)話框
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)