VEUI

VEUI on GitHub
Play!中文

FilterPanel

Examples

Browsers

Google Chrome
Apple Safari
Microsoft Edge
Mozilla Firefox
Opera
Vivaldi
Internet Explorer
Maxthon
Android Browser
UC Browser
Samsung Internet
QQ Browser
Edit this demo on GitHubEdit
<template>
<article>
  <veui-filter-panel
    title="Browsers"
    :datasource="browsersDatasource"
  >
    <template #default="{ items }">
      <div
        v-for="item in items"
        v-show="!item.hidden"
        :key="item.value"
        class="item"
      >
        {{ item.label }}
      </div>
    </template>
  </veui-filter-panel>
</article>
</template>

<script>
import { FilterPanel } from 'veui'

export default {
  components: {
    'veui-filter-panel': FilterPanel
  },
  data () {
    return {
      browsers: [
        'Google Chrome',
        'Apple Safari',
        'Microsoft Edge',
        'Mozilla Firefox',
        'Opera',
        'Vivaldi',
        'Internet Explorer',
        'Maxthon',
        'Android Browser',
        'UC Browser',
        'Samsung Internet',
        'QQ Browser'
      ]
    }
  },
  computed: {
    browsersDatasource () {
      return this.browsers.map(label => {
        return {
          label,
          value: label.toLowerCase().replace(/\s+/g, '-')
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.item {
  padding: 8px 15px;
}
</style>

API

Props

NameTypeDefaultDescription
datasourceArray<Object>[]Data source, with item type {label: string, ...}.
searchablebooleantrueWhether to allow searching.
filterfunctionSee description

Search filter function with signature function(keyword, item, index, datasource): boolean. Items with a return value of false will be filtered from the result.

NameTypeDescription
keywordstringSearch keyword.
itemObjectCurrent data node in the loop.
indexnumberIndex of the current data node in the sibling nodes.
datasourceArray<{label: string, ...}>Same as the datasource prop.
import { includes } from 'lodash'

function (keyword, { label }) {
  return includes(label, keyword)
}
search-on-inputbooleantrueWhether to trigger search on input.
placeholderstring-Placeholder for search box.
titlestring-Title of the filter panel.

Slots

NameDescription
headTitle area. Displays the title prop value by default.
no-dataContent displayed when there is no data in the datasource.
default

Main content area.

NameTypeDescription
itemsArray<Object>Filtered data from datasource, with the same type as datasource.
Edit this page on GitHubEdit
© Baidu, Inc. 2024