开源鸿蒙 @Entry
@Entry
The custom component decorated by @Entry functions as the default entry component of the respective page. When the page is loaded, the custom component decorated by @Entry is created and displayed first.
NOTE: A source file can contain at most one custom component decorated by @Entry.
Example of using @Entry:
// Only MyComponent decorated by @Entry is rendered and displayed. "hello world" is displayed, but "goodbye" is not displayed.
@Entry
@Component
struct MyComponent {
    build() {
        Column() {
            Text('hello world')
                .fontColor(Color.Red)
        }
    }
}
@Component
struct HideComponent {
    build() {
        Column() {
            Text('goodbye')
                .fontColor(Color.Blue)
        }
    }
}
你可能感兴趣的文章
开源鸿蒙 Multi-Language Capability
                        
                            0
                        
                        
                             赞
                        
                    
                    
                - 所属分类: 后端技术
 - 本文标签:
 
热门推荐
- 
                        2、 - 优质文章
 - 
                        3、 gate.io
 - 
                        7、 openharmony
 - 
                        9、 golang
 
 NOTE:
A source file can contain at most one custom component decorated by @Entry.