# The plug-in feature page

The plug-in feature page is supported starting with Weixin Mini Program base library version {% version ('2.1.0')%}.

Some interfaces cannot be called directly in plug-ins (e.g. wx.login ),But plug-in developers can use the plug-in feature page to implement the functionality. Currently, the plug-in feature page includes:

From the base library version {% version (2.22.1)%}, the following function pages have been deprecated, and the corresponding interface implementation functions can be directly invoked:

From the base library version {% version (2.16.1)%}, the following three function pages have been abandoned, and the corresponding interface can be directly invoked to implement functions;Original and newly used '`` will not jump to a feature page after a click, but will take effect directly:

To use the plug-in function page, activate the function page feature, configure the corresponding function page function, and then use the functional-page-navigator The component jumps to the plug-in feature page to implement the corresponding function. For more information, please refer to the following.

Before using the plugin feature page, you need to make sure that the plugin is enabled , otherwise it may appearfunctional-page-navigatorUnresponsive, etc.

# Plug-in owner Weixin Mini Program

Before we begin development, we need to know that the plug-in feature page is a special page in the plug-in owner Weixin Mini Program .

The plug-in owner Weixin Mini Program , refers to the Mini Program that is the same as the plug-in AppID.For example, the Mini Program sample Mini Program develops a Mini Program sample plug-in, so no matter which Mini Program is using the plug-in the Mini Program's plug-in owner Mini Program is a appletic sample Mini Program.We continue to use the term plug-in owner Mini Programs below.

# Plug-in Owner Weixin Mini Program Development Methods

Usually, when you start using the plug-in feature page, you need to open two developer tools windows, one to open the plug-ins project and the other to open the Mini Program project of the plug-int owner Weixin Mini Program.For example, one opens the "miniprogram sample plug-in" item and another opens the'miniprogram sample' item.

These two windows, the former for editing the plug-in, the latter for editing the plug-in owner Weixin Mini Program. All of the contents of the plug-in owner's Mini Program that need to be edited below are done in the latter.

# Activating feature page features

To invoke a plug-in feature page in a plug-in, you need to activate the feature page feature of the plug-in owner Weixin Mini Program.Specifically, add thefunctionalPagesdefinition segment to theapagejsonfile of the plug-in owner's Mini Program and have its value as [[]]true, for example:

Code example:

{
  "functionalPages": {
    "independent": true
  }
}

Currently, it is compatible with the old writing:

{
  "functionalPages": true
}

The old writing will be removed from support in the future and will not be able to compile and upload in the future.

The difference between these two ways is that the new way of writing"independent": trueThis makes the plug-in page's code independent of other code, which means that the plug-ins page can be downloaded and loaded independently, with better performance. But at the same time it makes the plug-in function pagesfunctional-pages /(The payment function page will use the files in it) cannot require files outside this directory (and vice versa: files outside this directory cannot call files inside this directory).

Note that when you add or change this field, you need a new version of this Weixin Mini Program release to use the plug-in feature page in a formal environment.

# Jump to the feature page

The function page cannot use wx.navigateTo to jump. Instead, it requires a function page named functional-page-navigator To obtain user information, for example, you can place the following functional-page-navigator in the plug-in:

Code example:

<functional-page-navigator name="loginAndGetUserInfo" args="" version="develop" bind:success="loginSuccess">
  <button>登录到插件</button>
</functional-page-navigator>

When the user clicks on thenavigator, it automatically jumps to the corresponding feature page of the plug-in owner Weixin Mini Program.The feature page prompts the user to log in or other appropriate actions. The results of the operation are returned as component events.

For the functional-page-navigator parameters and detailed usage, please refer to component explaination .

Starting with Weixin Mini Program base library version {% version ('2.4.0')%}, plug-in owner Mini Programs are supported to jump to their own feature pages.When the base library version is lower than {% version ('2.4.0')%}, click functional-page-navigator There will be no reaction.

# Routine steps for real-world development testing

At this time, the functionality page bounce is not currently supported for debugging in the developer tools. Please test it on a real machine. When a real-world development test is first performed, the usual steps are as follows:

  1. Open the Plugin Owner Weixin Mini Program project on the Developer Tools and click "Preview";
  2. Scan the preview code with the real machine for testing, and you will enter the plug-in owner Weixin Mini Program, and you can exit this Mini Program directly after entering;
  3. Open the plug-in project on the Developer Tools and add the functional-page-navigator Theversionattribute indevelop;
  4. Clicking on Preview can generate the plug-in preview QR code, and using a real-world scan for testing can preview the feature page; If you change the plug-in code, you can simply regenerate and scan the plug-ins preview QR code.
  5. If, after a while, the "developer version is out of date" prompt appears when you jump to the feature page, try again from step 1.

NOTE :functional-page-navigatorTheversion = developfor debugging purposes only, so before a plug-in can be reviewed, you need to:

  1. Make sure that the plugin owner"functionalPages" have been released: trueWeixin Mini Program;
  2. Make sure that allfunctional-page-navigatorcomponent properties are set toversion = "release".

# Frequently Asked Questions FAQ

# How do I edit the plugin owner Weixin Mini Program correctly?

  • It should be edited in the "Weixin Mini Program" type project of the developer tools, not in the "plug-in" type project. For example, the owner of the Mini Program sample plug-in is the Mini Program sample, and their AppIDs arewxidxxxxxxxxxxxxxxxx, If you are developing the Mini Program Sample Mini Program for the first time, you can create an Mini Program project in the developer tools with an AppID ofwxidxxxxxxxxxxxxxxxx; If you have developed a "miniprogram sample" Mini Program before, you can just open the previous Mini Program project.

# Click functional-page-navigator without any response.

  • Please check if Weixin Mini Program that refers to the plugin and the plugin itself are the same AppID. If so, the basic library {% version ('2.4.0') %} is required to jump to your own feature page, otherwise use functional-page-navigator will not respond.

# After clicking functional-page-navigator , a page saying "This page does not exist" is displayed.

  • This happens because the plug-in owner Weixin Mini Program has not properly set"functionalPages": true. If thefunctional-page-navigatorversion = "develop", This phone needs to scan the code and enter the plug-in owner's Mini Program once;Ifversion = "release", make sure to include"functionalPages": true`The plug-in owner Mini Program has been released.

# After clicking ", the pop-up prompt" Weixin Mini Program development version has expired. "

  • In this case, re-scan the code and enter the plug-in owner Weixin Mini Program once.

# Click '. After you've clicked on ', a page appears that says, 'This feature cannot be used.'

  • When using the plug-in feature page, Weixin Mini Program cannot be a personal Mini Program, At the same time, the plug-in also requires additional steps to apply for plug-in payment permissions (located in administration background -> Mini Program plug-ins]] -> Basic settings -> Payment capabilities).

# Click '.' After you have clicked the "Pay" button in the page, you immediately exit the payment feature page.

  • This is usually because the feature page functionbeforeRequestPaymentis not found. Check the Weixin Mini Program of the plugin ownerfunctional-pages / request-payment.jsfile andbeforeRequestPaymentfunction exist.

# After clicking functional-page-navigator , a page with only a back button is displayed.

# The development version can be redirected normally, but the review feedback cannot be redirect.

  • Please publish the plug-in owner Weixin Mini Program that has set"functionalPages": true, and allfunctional-page-navigatorComponent properties are set toversion = "release".

# Bugs & Tip

  • The feature page is a special page in the plug-in owner Weixin Mini Program, and the developer cannot customize the appearance of this page.
  • The plug-in owner Weixin Mini Program itself can reference the plug-in, in which casefunctional-page-navigatorTheversionattribute of the component will not take effect, but will depend on the version of the plug-in owner Mini Program currently running.
  • The functional-page-navigator can be used in the developer tools, but the function page jump does not currently support debugging in the developer tools, please test it on the real machine.
  • Bug: In WeChat version 6.6.7, when a feature page is pulled up, it triggers part of the app's life cycle and makes the feature page launch time longer.This behavior will change in subsequent versions of WeChat, so that the app life cycle will no longer be triggered.