Giter VIP home page Giter VIP logo

vue-picker-1's Introduction

vue-picker

基于vue2.x的picker

update

  • 2017-02-16 版本1.0.0
  • 2017-02-22 版本1.0.1 增加props验证
  • 2017-03-09 版本1.0.2 fix warning

效果截图

enter description here

使用场景

主要用于移动端选择器

demo运行

1 git clone

git clone https://github.com/jiaochunxiao/vue-picker.git

2 进入到仓库文件夹

npm install
//或者
cnpm install

3

npm run dev

使用说明

父组件中引入

<Picker
    ref='picker0'
    element='picker0'
    :data='pickerData[0]'
    @confirmAction='confirmFun'
    cols='2'
    :select-index='[1, 2]'
    @hidePicker='hidePicker'
    :invalid="['李四', '搞笑']"
>
</Picker>
<Picker
    ref='picker1'
    element='picker1'
    :data='pickerData[1]'
    @confirmAction='confirmFun'
    cols='3'
    :select-index='[4, 0, 0]'
    @hidePicker='hidePicker'
    :is-link='true'
    :invalid='["","合肥市","高新区"]'
>
</Picker>
<Picker
    ref='picker2'
    element='picker2'
    :data='pickerData[2]'
    @confirmAction='confirmFun'
    cols='3'
    :is-async='true'
    @hidePicker='hidePicker'
>
</Picker>
<Picker
    ref='picker3'
    element='picker3'
    :data='pickerData[3]'
    :selectVal='selectValDate'
    cols='3'
    @hidePicker='hidePicker'
    @confirmAction='confirmFun'
    @changePicker='changePickerForDate'
>
</Picker>

组件中props值:

props:{
	'show': {
		type: Boolean,//是否显示
		default: false
	},
	'selectIndex': {//选中的选项的索引
        type: Array
    },
    'selectVal': {//选中的选项的值
        type: Array
    },
	'title':{//弹层中间的标题
		type: String,
		default: ''
	},
	'cancelText':{//取消操作的显示文案
		type: String,
		default: '取消'
	},
	'confirmText': {//确定操作的显示文案
		type: String,
		default: '确定'
	},
	'element':{//关联的元素
		type: String,
		default: ''
	},
	'data':{
		type: Array,//
		default: function(){
			return []
		}
	},
	'invalid':{//不能被选中的选项
		type: Array,
		default: function(){
			return []
		}
	},
	'cols':{//picker列数
		default:''
	},
	'isAsync': {//是否异步
        type: Boolean,
        default: false
    },
    'isLink': {//是否需要联动
		type: Boolean,
		default: false
    },
    'hidePicker':{//隐藏时触发的方法
		type: Function,
		default: function(){}
    },
	'changePicker': {//picker滚动时触发的方法
		type: Function,
		default: function(){}
	},
	'confirmAction': {//确定时触发的方法
		type: Function,
		default: function(){}
	}
}

后记

本组件主要基于 Huangyi 的wheel插件和公司同事的vue 1.x的picker组件,在数据交互部分绝大部分保留,针对Vue1.x升级Vue2.x,做了部分修改和开发。

vue-picker-1's People

Contributors

jiaochunxiao avatar

Watchers

 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.