tree: 0b98feb0e7fb79f33e56cc45dd0bf312b64c28a2 [path history] [tgz]
  1. index.js
  2. index.vue
  3. option.vue
  4. package.json
  5. README.md
  6. README_cn.md
packages/wxc-grid-select/README.md

wxc-grid-select

Grid selection component supports single and multiple choice

Demo

Code Example

<template>
  <wxc-grid-select
    :single="true"
    :cols="5"
    :customStyles="customStyles"
    :list="testData1"
    @select="params => onSelect('res3', params)">
  </wxc-grid-select>
  
  <wxc-grid-select
    :limit="5"
    :list="testData2"
    @overLimit="onOverLimit"
    @select="params => onSelect('res3', params)">
  </wxc-grid-select>
</template>
<script>
  import { WxcGridSelect } from 'weex-ui';
  export default {
    components: { WxcGridSelect },
    data: () => ({
      customStyles: {
        lineSpacing: '14px',
        width: '120px',
        height: '50px',
        icon: '',
        color: '#333333',
        checkedColor: '#ffffff',
        disabledColor: '#eeeeee',
        borderColor: '#666666',
        checkedBorderColor: '#ffb200',
        backgroundColor: '#ffffff',
        checkedBackgroundColor: '#ffb200'
      },
      testData1: [
        {
          'title': 'shanghai'
        },
        {
          'title': 'hangzhou',
          'checked': true
        },
        {
          'title': 'beijing'
        },
        {
          'title': 'guangzhou'
        },
        {
          'title': 'shengzhen'
        },
        {
          'title': 'nanjin'
        }
      ],
      testData2: [
        {
          'title': 'shanghai'
        },
        {
          'title': 'hangzhou',
          'checked': true
        },
        {
          'title': 'beijing',
          'checked': true
        },
        {
          'title': 'guangzhou'
        },
        {
          'title': 'shengzhen'
        },
        {
          'title': 'nanjing'
        }
      ]
    }),
    methods: {
      onSelect (res, {selectIndex, checked, checkedList}) {
        Vue.set(this, res, `checked index${selectIndex}:${checked ? 'yes' : 'no'}\n checked list${checkedList.map(item => item.title).join(',')}`);
      },
      onOverLimit (limit) {
        modal.toast({
          message: `${limit}`,
          duration: 0.8
        });
      }
    }
  }
</script>

More details can be found in here

Props

PropTypeRequiredDefaultDescription
listArrayY-config data list
list[{title}]StringN''title
list[{checked}]BooleanNfalsewhether is checked
list[{disabled}]BooleanNfalsewhether is been disabled
singleBooleanNfalsewhether is single choice
limitNumberN-maximum number of choices
colsNumberY4cols
customStylesObjectN{}custom styles
customStyles{lineSpacing}StringN12pxlineSpacing
customStyles{width}StringN166pxitem width
customStyles{height}StringN72pxitem height
customStyles{color}StringN#3d3d3dtext color
customStyles{checkedColor}StringN#3d3d3dchecked text color
customStyles{disabledColor}StringN#9b9b9bdisabled text Color
customStyles{borderColor}StringNtransparentborder color
customStyles{checkedBorderColor}StringN#ffb200checked border color
customStyles{disabledBorderColor}StringNtransparentdisabled border color
customStyles{backgroundColor}StringN#f6f6f6background color
customStyles{checkedBackgroundColor}StringN#ffffffchecked background color
customStyles{disabledBackgroundColor}StringN#f6f6f6disabled background color
customStyles{icon}StringNxicon when checked

Events

select

  • data:
    {
      selectIndex:1
      checked: true
      checkedList:[1,2,3,4]
    }
    
  • demo:
    <wxc-grid-select @select="onSelect"></wxc-grid-select>
    

overLimit

  • data:
    arg1: limit count
    
  • demo:
    <wxc-grid-select @overLimit="onOverLimit"></wxc-grid-select>