Use Custom Component

Use Custom Component

Note:
The event of custom component (such as onTap) is not supported by every custom component by default. It cannot be used unless the custom component itself supports clearly. For details on custom component support event, see the section of component constructor.
The use of custom component is similar to the basic component.
1. In the page json file, specify the custom component to be used.

copy
// /pages/index/index.json
{
  "usingComponents": {
    "customer": "/components/customer/index"
  }
}
  1. In the page axml file, use the custom component, which is similar to the basic components.
copy
<!-- /pages/index/index.axml -->
<view>
  <customer />
</view>

Citing Custom Component:

copy
// page.json  Note that it is not configured in app.json 
{
  "usingComponents":{
    "your-custom-component":"mini-antui/es/list/index",
    "your-custom-component2":"/components/card/index",
    "your-custom-component3":"./result/index",
    "your-custom-component4":"../result/index"
  }
}
// The project absolute path starts with /; the relative path starts with ./ or ../; the npm path does not start with /

Reference Information

For installing the npm module, see framework overview npm part