spz-filter
布局
Layouts
跳转到“Layouts”Usage
跳转到“Usage”<spz-filter
manual
layout="logic"
id="collection-filter"
content-id="filter-content"
result-id="filter-result"
list-id="collection-list"
src="/api/collections//filters"
keep-behavior="filter"
></spz-filter>
<spz-list
layout="container"
id="collection-list"
...
></spz-list>
Attributes
跳转到“Attributes”src
跳转到“src”required
You can use either a URL API or a script:#script_id
to get data of the filter.
list-id
跳转到“list-id”required
Specifies which the data of the spz-list
to sort or filter.
content-id
跳转到“content-id”required
Specifies the element id for rendering filtered data.
It must have a locale-map
attribute to to set the specified content.
Its child elements must be an spz-render
. They can have a label
as a attribute. If the label
is equal to an spz-render
attribute, it will be rendered. Otherwise it will be rendered by an spz-render
with the default
attribute. The spz-render
must have a manual
attribute.
<script id="filter-locale-json" type="application/json">
{
"availability": {
"title": "Availability",
"in_stock": "In stock",
"out_of_stock": "Out of stock"
},
"price": "Price",
"vendor": "vendor"
}
</script>
<div id="filter-content" locale-map="filter-locale-json">
<spz-render layout="container" manual default>
<template>
<!-- ... -->
</template>
</spz-render>
<spz-render layout="container" manual price>
<template>
<!-- ... -->
</template>
</spz-render>
</div>
result-id
跳转到“result-id”required
Specifies the element id for rendering filtered results.
If the child element has a delete
attribute, the user clicks on it and it will be deleted.
If the child element has a clear
attribute, the user clicks on it and the filter results will be cleared.
<div id="filter-result">
<spz-render default manual layout="container">
<template>
<div delete>
<!-- ... -->
</div>
</template>
</spz-render>
<spz-render price manual layout="container">
<!-- ... -->
</spz-render>
<div clear>Clear all</div>
</div>
manual
跳转到“manual”If this attribute is present, the template doesn’t render at the beginning.
keep-behavior
跳转到“keep-behavior”Get relevant parameters from URL to generate initial filter results. It has the following values:
filter
: Getfilter
related parameters from URL to apply to filter results.tags
: Gettags
related parameters from the URL to apply to the filter results
track-event-name
跳转到“track-event-name”A string of the event name. Report data when the element is changed.
Actions
跳转到“Actions”show
跳转到“show”To show filter when the spz-filter
has a manual
attribute, no parameter required.
apply
跳转到“apply”To apply selected data to filter, no parameter required.
rerender
跳转到“rerender”To re-render.
Parameter | Description | Type | Required |
---|---|---|---|
label | Specified a filter option label | string | No |
delete
跳转到“delete”To delete a filter result. Elements using this action need to have a category
attribute. No parameter required.
clear
跳转到“clear”To clear all filters. No parameter required.
update
跳转到“update”Re-request data to render filter. No parameter required.