generic component in wechat mini

Generic Item View

In our example omponent, we have a item-view custom component that will be applied as a generic component.

pages/example/example.wxml

In other pages, when we create a generic component and create a tag called selectable. You can name this whatever you want.

For example, in custom component pageView page-view’s index.json and index.wml, we declare custom generic tag called “rickycao” under componentGeneric:

index.json

Then use it in the wx html file like this:

index.wxml

In order to use rickycao tag, it is looking for a custom component that serves as generic (as indicated in componentGenerics). So when we use
the tag rickycao, we know which custom component to use.

In order to provide this generic, we must do so like this:

generic:rickytsao, and as a property of using our pageView component.

example.wxml

where item-view is declared in:

example.json

Let’s use the custom tag itemview

components/page-view/index.json

Then in that wx html file, we use it as a tag and then insert our values into its properties.

components/page-view/index.wxml

We use a custom component, and then say that we are applying our item-view component as a generic component: