权限

申请权限

外部网址图片,配置module.json5

1"requestPermissions": [ 2 { 3 "name": "ohos.permission.INTERNET" 4 } 5],
"requestPermissions": [ { "name": "ohos.permission.INTERNET" } ],

3秒跳转

1aboutToAppear(): void { 2 setTimeout(() => { 3 router.replaceUrl({ 4 url: 'pages/Index' 5 }) 6 }, 3000) 7}
aboutToAppear(): void { setTimeout(() => { router.replaceUrl({ url: 'pages/Index' }) }, 3000) }

倒计时

 1import { BasicConstants } from '../constants/BasicConstants';  2import { router } from '@kit.ArkUI'  3  4@Entry  5@Component  6struct Page02_GuidePage {  7 @State message: string = 'Hello World';  8 @State count: number = 3  9 private timer: number = 0 10 11 aboutToAppear(): void { 12 this.timer = setInterval(() => { 13 this.count-- 14 if (this.count == 0) { 15 router.replaceUrl({ 16 url: 'pages/Index' 17 }) 18 } 19 }, 1000) 20 } 21 22 aboutToDisappear(): void { 23 clearInterval(this.timer) 24 } 25 26 build() { 27 Stack({ 28 alignContent: Alignment.TopEnd 29 }) { 30 Text(`倒计时:${this.count}`) 31 .margin({ 32 right: 10 33 }) 34 Flex({ 35 direction: FlexDirection.Column, 36 alignItems: ItemAlign.Center 37 }) { 38 // logo 39 Column() { 40 Image($r('app.media.bird')) 41 .width(200) 42 .borderRadius(10) 43 } 44 .justifyContent(FlexAlign.Center) 45 .alignItems(HorizontalAlign.Center) 46 .flexGrow(1) 47 48 Image($r('app.media.startIcon')) 49 .width(28) 50 .objectFit(ImageFit.Contain) 51 52 Text('WoniuMall超市') 53 .fontColor('#66000000') 54 .fontSize(20) 55 .letterSpacing(16) 56 .margin({ 57 top: 12, 58 bottom: 136 59 }) 60 } 61 .width(BasicConstants.FULL_WIDTH) 62 .height(BasicConstants.FULL_HEIGHT) 63 } 64 } 65}
import { BasicConstants } from '../constants/BasicConstants'; import { router } from '@kit.ArkUI' @Entry @Component struct Page02_GuidePage { @State message: string = 'Hello World'; @State count: number = 3 private timer: number = 0 aboutToAppear(): void { this.timer = setInterval(() => { this.count-- if (this.count == 0) { router.replaceUrl({ url: 'pages/Index' }) } }, 1000) } aboutToDisappear(): void { clearInterval(this.timer) } build() { Stack({ alignContent: Alignment.TopEnd }) { Text(`倒计时:${this.count}`) .margin({ right: 10 }) Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { // logo Column() { Image($r('app.media.bird')) .width(200) .borderRadius(10) } .justifyContent(FlexAlign.Center) .alignItems(HorizontalAlign.Center) .flexGrow(1) Image($r('app.media.startIcon')) .width(28) .objectFit(ImageFit.Contain) Text('WoniuMall超市') .fontColor('#66000000') .fontSize(20) .letterSpacing(16) .margin({ top: 12, bottom: 136 }) } .width(BasicConstants.FULL_WIDTH) .height(BasicConstants.FULL_HEIGHT) } } }

Powered By 可尔物语

浙ICP备11005866号-12