Code Monkey home page Code Monkey logo

vue-picker's Introduction

中文 | 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)

vue-picker's People

Contributors

naihe138 avatar momopig avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.