Skip to main content
Version: Next

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.

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

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

Reference

Type

ComponentType<OfficialAccountProps>

OfficialAccountProps

PropertyTypeRequiredDescription
onLoadBaseEventOrigFunction<detail>NoTriggered when the component is loaded successfully.
onErrorBaseEventOrigFunction<detail>NoTriggered when the component fails to be loaded.

Property Support

PropertyWeChat Mini-ProgramH5React Native
OfficialAccountProps.onLoad✔️
OfficialAccountProps.onError✔️

detail

detail object

PropertyTypeDescription
statusnumberStatus code
errMsgstringError message

status

Valid values of status

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

API Support

APIWeChat Mini-ProgramH5React Native
OfficialAccount✔️