ais-query-rule-custom-data
<ais-query-rule-custom-data // Optional parameters :transform-items="function" />
1
2
3
4
5
6
7
8
9
import { AisQueryRuleCustomData } from 'vue-instantsearch';
// Use 'vue-instantsearch/vue3/es' for Vue 3
export default {
components: {
AisQueryRuleCustomData
},
// ...
};
1. Follow additional steps in Optimize build size to ensure your code is correctly bundled.
2. This imports all the widgets, even the ones you don鈥檛 use. Read the Getting started guide for more information.
About this widget
The ais-query-rule-custom-data
widget displays custom data from Rules.
You may want to use this widget to display banners or recommendations returned by Rules, and that match search parameters.
Examples
1
2
3
4
5
6
7
8
9
10
11
<ais-query-rule-custom-data>
<template v-slot:item="{ item }">
<h2>{{ item.title }}</h2>
<a :href="item.link">
<img
:src="item.banner"
:alt="item.title"
/>
</a>
</template>
</ais-query-rule-custom-data>
Props
Parameter | Description | ||
---|---|---|---|
transform-items
|
type: function
Optional
Receives the items and is called before displaying them. Should return a new array with the same shape as the original array. Useful for transforming, removing, or reordering items. In addition, the full |
||
Copy
|
Customize the UI
Parameter | Description | ||
---|---|---|---|
default
|
The slot to override the complete DOM output of the widget. The following example assumes a Query Rule returned this custom data.
Copy
Note that when you implement this slot, none of the other slots will change the output, as the default slot surrounds them. Scope
|
||
Copy
|
|||
item
|
The slot to override the DOM output of the item returned by the Rules. The following example assumes a Query Rule returned this custom data.
Copy
Scope
|
||
Copy
|
HTML output
1
<div class="ais-QueryRuleCustomData"></div>