1e41f4b71Sopenharmony_ci# Widget Switching 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciWidget switching involves the following parts: 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ci- Widget UI layout: Both the FA model and stage model use the web-like paradigm to develop the widget UI layout. Therefore, the UI layout of a widget in the FA model can be directly reused in the stage mode. 8e41f4b71Sopenharmony_ci- Widget configuration file: Widgets are configured in the **config.json** file in the FA model and in **module.json5** and **form_config.json** files in the stage model (as shown in Figure 1 and Figure 2). 9e41f4b71Sopenharmony_ci- Widget service logic: The widget entry file and lifecycle of the FA model are slightly different from those of the stage model, as shown in Figure 3 and Figure 4. 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci| Configuration Item | FA Model | Stage Model | 12e41f4b71Sopenharmony_ci| ---------------- | ------------------------------------------- | ------------------------------------------------------------ | 13e41f4b71Sopenharmony_ci| Configuration item location | **formAbility** and **forms** are in the **config.json** file.| **extensionAbilities** (configuration for **formExtensionAbility**) is in the **module.json5** file in the level-1 directory, and **forms** (configuration for **forms** contained in **formExtensionAbility**) is in the **form_config.json** file in the level-2 directory.| 14e41f4b71Sopenharmony_ci| Widget code path | Specified by **srcPath**, without the file name. | Specified by **srcEntry**, with the file name. | 15e41f4b71Sopenharmony_ci| Programming language | **srcLanguage** can be set to **js** or **ets**. | This configuration item is unavailable. Only ets is supported. | 16e41f4b71Sopenharmony_ci| Whether to enable widgets | formsEnabled | This configuration item is unavailable. When **type** is set to **form**, widgets are enabled. | 17e41f4b71Sopenharmony_ci| Ability type | type: service | type: form | 18e41f4b71Sopenharmony_ci| Level-2 directory configuration tag| This configuration item is unavailable. | **metadata**, which consists of **name**, **value**, and **resource**, where **resource** points to the location of the **form_config.json** file in the level-2 directory.| 19e41f4b71Sopenharmony_ci 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciFigure 1 Entry configuration differences 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ciFigure 2 Widget configuration differences 28e41f4b71Sopenharmony_ci 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci| Item| FA Model| Stage Model| 34e41f4b71Sopenharmony_ci| -------- | -------- | -------- | 35e41f4b71Sopenharmony_ci| Entry file| **form.ts** in the directory pointed to by **srcPath**| File pointed to by **srcEntry**| 36e41f4b71Sopenharmony_ci| Lifecycle| export default| import FormExtension from '\@ohos.app.form.FormExtensionAbility';<br>export default class FormAbility extends FormExtension| 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ciFigure 3 Entry file differences 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ciFigure 4 Lifecycle differences (The lifecycle callbacks are the same and require no adjustment.) 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci 49