All Projects → naihe138 → Vue Picker

naihe138 / Vue Picker

Licence: mit
A picker componemt for vue

Labels

中文 | English

vue-picker的组件,囊括了(普通选择联动选择中国地址选择)等等常见的picker,兼容PC、移动端,通过简单配置就可以出现一个强大的picker,感受下效果图。

vue-pick.gif

Demo(快点去复制代码体验一波吧)

https://naihe138.github.io/vue-picker/index.html

Install

npm install vue-pickers --save or yarn add vue-pickers

使用

普通网页开发直接复制lib/vue-picker.js文件夹到项目即可直接使用

<template>
  <div>
    <button @click="show">show picker</button>
    <VuePicker :data="pickData"
      :showToolbar="true"
      @cancel="cancel"
      @confirm="confirm"
      :visible.sync="pickerVisible"
    />
  </div>
</template>

<script>
  import VuePicker from 'vue-pickers'
  var tdata = []
  for (let i = 0; i < 20; i++) {
    tdata.push({
      label: '第' + i + '行',
      value: i
    })
  }
  export default {
    components: {
      VuePicker
    },
    data () {
      return {
        pickerVisible: false,
        pickData: [
          tdata
        ],
        result: ''
      }
    },
    methods: {
      show () {
        this.pickerVisible = true
      },
      cancel () {
        this.result = 'click cancel result: null'
      },
      confirm (res) {
        this.result = JSON.stringify(res)
      }
    }
  }
</script>

属性参数说明

参数 说明 是否必须 类型 默认值
visible 显示/隐藏picker Boolean false
data pickerData,多列[data1, data2] Array []
layer 联动显示列数 Number 0
defaultIndex 默认显示的index Number/Array(多列用数组)
cancelText 取消按钮文字 String '取消'
confirmText 去确认按钮文字 String '确认'
title picker标题 String ''
showToolbar 显示头部 Boolean false
maskClick 遮罩层是否可以点击关闭 Boolean false
itemHeight 每一行的高度 Number, String '44px'
rowNumber 显示多少行(建议单数) Number 5
appendToBody 是否插入到body中 Boolean false

事件说明

参数 说明 是否必须 类型 默认值
change 数据变化事件 function(val)
cancel 取消选择 function
confirm 确认选择 function(val)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].