title: OfficialAccount

sidebar_label: OfficialAccount

The Official Account following component. You can add this component to a Mini Program, to help a user conveniently follow an Official Account after the user opens the Mini Program by scanning the Mini Program code. This component can be nested into a native component.

Tips

  1. Before using this component, you need to go to Mini Program Console, and choose Settings > API Settings > Official Account Following Component to set the Official Account to be displayed. Note: The Official Account and the Mini Program must belong to the same entity.

  2. During the lifecycle of a Mini Program, the capability of displaying the Official Account following component is available only when the Mini Program is opened in any of the following scenarios:

    • The Mini Program is opened by scanning the Mini Program code (scene value 1047).

    • When the Mini Program is opened from Recently Used at the top of the Chats screen (scene value 1089), if the Mini Program is not destroyed, the component remains in the same state as that when the Mini Program was last opened.

    • When returning to the Mini Program from another Mini Program (scene value 1038), if the Mini Program is not destroyed, the component remains in the same state as when the Mini Program was opened last time.

  3. The minimum width of the component is limited to 300 px and the height is fixed at 84 px.

  4. Each page can include only one Official Account following component.

Reference

Type

  1. ComponentType<OfficialAccountProps>

OfficialAccountProps

Property Type Required Description
onLoad BaseEventOrigFunction<detail> No Triggered when the component is loaded successfully.
onError BaseEventOrigFunction<detail> No Triggered when the component fails to be loaded.

Property Support

Property WeChat Mini-Program H5 React Native
OfficialAccountProps.onLoad ✔️
OfficialAccountProps.onError ✔️

detail

detail object

Property Type Description
status number Status code
errMsg string Error message

status

Valid values of status

Value Description
-2 Network error
-1 Data parsing error
0 Loading succeeded
1 The Official Account following feature in the Mini Program is suspended
2 Linked Official Account is suspended
3 The Official Account is unlinked or not selected
4 The Official Account following feature is disabled
5 Scene value error
6 Repeated creation

API Support

API WeChat Mini-Program H5 React Native
OfficialAccount ✔️