ts-component-based-entry.md 943 字节
Newer Older
Z
zengyawen 已提交
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
# @Entry<a name="EN-US_TOPIC_0000001110788998"></a>

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.

>![](../../public_sys-resources/icon-note.gif) **NOTE:** 
>A source file can contain at most one custom component decorated by  **@Entry**.

## Example<a name="section0615954173414"></a>

Sample code for 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)
        }
    }
}
```