服务器 API:生命周期
🌐 Server API: Lifecycle
Page summary:服务器 API 有 3 个生命周期函数。在应用完全初始化之前,使用
register()声明功能;初始化 Strapi 后,使用bootstrap()运行逻辑;关闭时,使用destroy()清理资源。每个函数都接收{ strapi }作为其参数。
生命周期函数控制插件的服务器端逻辑在 Strapi 应用启动和关闭过程中何时运行。它们与路由、控制器、服务和其他服务器模块一起从服务器入口文件导出。
🌐 Lifecycle functions control when your plugin's server-side logic runs during the Strapi application startup and shutdown sequence. They are exported from the server entry file alongside routes, controllers, services, and other server blocks.
Prerequisites
在深入了解本页的概念之前,请确保你已经:
🌐 Before diving deeper into the concepts on this page, please ensure you have:
- 创建了一个 Strapi 插件,
- 已阅读并理解了服务器 API的基础知识
启动序列
🌐 Startup sequence