Applications pages(应用页面(Applications pages))¶
Pages offer application builders the ability to split application UI, logic, and resources (for example, queries, variables, functions, and events) into different pages within a single application, providing isolated scope for each page that loads separately.
Splitting up the logic of a complex Slate application into pages not only simplifies refactoring but also enhances stability, maintainability, and performance. By using pages and shared variables effectively, developers can create well-organized, efficient applications that elevate both performance and user experience.
Create a new page¶
To add a page to a Slate application:
- Select the + option in the Pages panel.
- Enter the page name.

:::callout{theme="neutral"} You can share a link directly to a specific page within a Slate application by using a page's name in the URL. :::

Delete a page¶
To delete a page from a Slate application, open the ... dropdown menu in-line with the specific page in the Pages panel, then select Delete.

Navigate between pages¶
The onNavigate[page_name] event and navigateTo[page_name] action allow for simple navigation between pages within the same application.
The URL updates accordingly when navigating between pages.
State sharing between pages¶
"Application state" refers to the condition or status of an application at any given moment. It encompasses all the variables, user inputs, settings, and configurations that can influence the behavior and output of the application.
For instance, in a shopping app, the application state might include the items a user has added to their cart, the user's preferences, whether the user is logged in or not, and so on.
Sharing application state between pages is done using shared variables which can be referenced from any page across the entire application.
For example, a function or user interaction on one page can set or modify the value of a shared variable, while another page can read from and use that value to allow for cross-page communication.

Use the user storage variable to store application state information for individual users that needs to persist across application loads, such as user preferences for a specific application. The user storage variable is also accessible from any page across the application.
中文翻译¶
应用页面(Applications pages)¶
页面(Pages)使应用构建者能够将应用的用户界面、逻辑和资源(例如查询、变量、函数和事件)拆分到单个应用内的不同页面中,为每个独立加载的页面提供隔离的作用域。
将复杂 Slate 应用的逻辑拆分为多个页面,不仅能简化重构过程,还能增强稳定性、可维护性和性能。通过有效利用页面和共享变量(shared variables),开发者可以创建组织有序、高效的应用,从而提升性能和用户体验。
创建新页面¶
要向 Slate 应用添加页面:
- 在页面(Pages)面板中选择 + 选项。
- 输入页面名称。

:::callout{theme="neutral"} 您可以通过在 URL 中使用页面名称,直接分享 Slate 应用中特定页面的链接。 :::

删除页面¶
要从 Slate 应用中删除页面,请打开页面(Pages)面板中对应页面行内的 ... 下拉菜单,然后选择删除(Delete)。

在页面间导航¶
onNavigate[page_name] 事件和 navigateTo[page_name] 操作支持在同一应用内的页面间进行简单导航。
在页面间导航时,URL 会相应更新。
页面间的状态共享¶
"应用状态(Application state)"指的是应用在任意时刻的条件或状态。它包含所有可能影响应用行为和输出的变量、用户输入、设置和配置。
例如,在购物应用中,应用状态可能包括用户添加到购物车的商品、用户偏好、用户是否登录等。
页面间的应用状态共享通过共享变量(shared variables)实现,这些变量可在整个应用的任何页面中引用。
例如,一个页面上的函数或用户交互可以设置或修改共享变量的值,而另一个页面可以读取并使用该值,从而实现跨页面通信。

使用用户存储变量(user storage variable)来存储需要在应用加载间持久化的单个用户的应用状态信息,例如特定应用的用户偏好。用户存储变量也可从应用的任何页面访问。