2.2.5 • Published 6 years ago

vue-pickers-test v2.2.5

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

vue-picker

a picker componemt for vue2.0


走了一圈 github 都没有找到自己想要的移动端的 vue-picker的组件,于是自己就下手,撸了一个出来,感受下效果图。 vue-pick.gif

demo

demo 地址:http://gitblog.naice.me/vue-picker/example/index.html

install

npm install vue-pickers --save

使用

<template>
  <div>
    <vue-pickers
      :show="show"
      :columns="columns"
      :defaultData="defaultData"
      :selectData="pickData"
      @cancel="close"
      @confirm="confirmFn"></vue-pickers>
  </div>
</template>

<script>
import vuePickers from 'vue-pickers'
export default {
  components: {
    vuePickers
  },
  data() {
    return {
      show: false,
      columns: 1,
      defaultData: [
        {
          text: 1999,
          value: 1999
        }
      ],
      pickData: {
        // 第一列的数据结构
        data1: [
          {
            text: 1999,
            value: 1999
          },
          {
            text: 2001,
            value: 2001
          }
        ]
      }
    }
  },
  methods: {
    close() {
      this.show = false
    },
    confirmFn(val) {
      this.show = false
      this.defaultData = [val.select1]
    },
    toShow() {
      this.show = true
    }
  }
}
</script>

属性参数说明

参数说明是否必须类型默认值
show显示隐藏pickerBooleanfalse
columns列数设置Number1
defaultData默认显示设置Array[]
link是否开启联动数据Booleanfalse
selectData数据设置,分别对应列(data1: [], data2: [], data3: [],)Object{}

事件说明

参数说明是否必须类型默认值
cancel取消选择function
confirm确认选择function(val)