This is an overview of the most common usage of Page. For more information about the available properties, methods, or events, head over to the complete API documentation for Page.
<Page>
is a UI component that represents an application screen. NativeScript apps typically consist of one or more <Page>
that wrap content such as an <ActionBar>
and other UI widgets.
<Page>
<ActionBar title="My App" />
<GridLayout>
<Label text="My Content"/>
</GridLayout>
</Page>
loaded
event for triggering UI changesA typical scenario is performing UI changes after the page is loaded. The recommended way to do it is by using the loaded
event, triggered by NativeScript when the page is fully loaded:
<Page @loaded="greet">
<ActionBar title="My App" />
<GridLayout>
<Label text="My Content"/>
</GridLayout>
</Page>
export default {
methods: {
greet() {
alert('Hello!').then(() => {
console.log('Dialog closed')
})
}
}
}
NOTE: Developers coming from a web background would usually reach for the
mounted
lifecycle hook Vue provides, however in NativeScript the application, and certain elements might not yet be loaded when themounted
hook is executed, thus certain actions such as alerts, dialogs, navigation etc. are not possible inside themounted
hook. To work around this limitation, theloaded
event may be used, which only fires after the application is ready. In this case, we are using theloaded
event of the<Page>
element, but this event is available for all NativeScript elements.
Name | Type | Description |
---|---|---|
actionBarHidden | Boolean | Shows or hides the <ActionBar> for the page.Default value: false . |
backgroundSpanUnderStatusBar | Boolean | Gets or sets whether the background of the page spans under the status bar. Default value: false . |
androidStatusBarBackground | Color | (Android-only) Gets or sets the color of the status bar on Android devices. |
enableSwipeBackNavigation | Boolean | (iOS-only) Gets or sets whether the page can be swiped back on iOS. Default value: true . |
statusBarStyle | String | Gets or sets the style of the status bar. Valid values: light ,dark . |
Name | Description |
---|---|
loaded | Emitted after the page has been loaded. |
navigatedFrom | Emitted after the app has navigated away from the current page. |
navigatedTo | Emitted after the app has navigated to the current page. |
navigatingFrom | Emitted before the app has navigated away from the current page. |
navigatingTo | Emitted before the app has navigated to the current page. |
Android | iOS |
---|---|
org.nativescript.widgets.GridLayout | UIViewController |