aro supports the use of pages, components and plugins that are native to the mini program.
Note: If pages, components and plugins native to the mini program are referenced in the Taro project, the project will no longer have the ability to convert to multiple ends. For example, if the native components of WeChat mini programs are used, then the project can only be converted to WeChat mini programs, escaping to other platforms will fail, same for using other mini program native components.
1. Configure the
usingComponents property in the app or page configuration file.#
Note: Taro3 components do not have profiles, so usingComponents must be configured in the "page" profile.
The attribute names remain consistent with the native syntax.
Note: In Vue, if some properties of a component have the default value
true, they still need to be explicitly set to true when used in Taro.
Event binding in
React requires a hump form starting with
on (instead of
bind in the native binding syntax).
The event binding of
Vue is written in the same way as the native one.
This is implemented in
React using the
Vue using the
You can use the
selectComponent API of the mini program page instance to get an instance of a third-party native component.
Just set up the routing of the native page in the app configuration.
Before using the plugin, the user has to declare the plugin to be used in the configuration of
app.confg.js, for example
As shown in the example above, the
plugins definition segment can contain multiple plugin declarations, each identified by a user-defined plugin reference name and specifying the plugin's
appid and the version number to be used. The reference name (e.g. myPlugin in the above example) is user-defined and does not need to be consistent with or coordinated with the plugin developer. This reference name will be used to represent the plugin in subsequent uses of the plugin.
To use a custom component provided by a plugin, similar to the "introduce third-party components" approach described above, use the
plugin:// protocol to specify the reference name of the plugin and the name of the custom component when defining the custom component to be introduced in the configuration of the page or component, eg:
For the protection of plugins, the custom components provided by plugins are subject to certain restrictions on their use.
- (a) By default, the
this.$scope.selectComponentinterface on the page cannot obtain the custom component instance object of the plugin.
>>>selectors of interfaces such as
Taro.createSelectorQuerycannot be selected inside the plugin.
The plugin's pages are supported from mini program base library version 2.1.0.
When you need to jump to the plugin page, the url is prefixed with
When using the
js interface of a plugin, you can use the
Taro.requirePlugin method. For example, if the plugin provides a method named
hello and a variable named
world, it can be called like this.