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 60 61 62 63 64 65
| package ohos_app_cangjie_entry
import ohos.base.* import ohos.component.* import ohos.state_manage.* import ohos.state_macro_manage.* import ohos_app_cangjie_entry.pages.* import ohos_app_cangjie_entry.bean.* import ohos_app_cangjie_entry.api.* import ohos.router.* import std.collection.* import encoding.json.* import serialization.serialization.* import ohos.hilog.* import ohos.resource_manager.*
@Entry @Component class MyView { @State var message: String = "Hello Cangjie" var controller: TabsController = TabsController() @State var currentIndex: Int32 = 0
protected override func onPageShow() {
} func build() { Column() { Tabs(BarPosition.End, this.controller) { TabContent { TabContentView(currentIndex:this.currentIndex) } .tabBar(icon: getResourceMedia(@r(app.media.startIcon)), text: "Tab1") .id("tab0") TabContent { TabContentView(currentIndex:this.currentIndex) } .tabBar(icon: getResourceMedia(@r(app.media.startIcon)), text: "Tab2") .id("tab1") TabContent() { TabContentView(currentIndex:this.currentIndex) } .tabBar(icon: getResourceMedia(@r(app.media.startIcon)), text: "Tab3") .id("tab2") TabContent() { TabContentView(currentIndex:this.currentIndex) } .tabBar(icon: getResourceMedia(@r(app.media.startIcon)), text: "Tab4") .id("tab3") } .vertical(false) .scrollable(true) .barMode(BarMode.Fixed) .barWidth(100.percent) .barHeight(70) .animationDuration(400) .width(100.percent) .backgroundColor(0xF5F5F5) .onChange({index: Int32 => this.currentIndex = index}) } .width(100.percent) .height(100.percent) .margin(top: 5) } }
|