Code Monkey home page Code Monkey logo

uni-sofar-picker's Introduction

sofar-picker

  • 日期范围选择,颗粒度为年-月,支持至今选项。
  • 也是根据开发需求去借鉴其他代码后完成的,分享出来希望有帮助。
  • 最新的项目示例代码可在GitHub获取。

使用方法

script 中引用组件

import sofarPicker from '@/components/sofar-picker/sofar-picker.vue'
export default {
  components: {
    sofarPicker
  }
}

template 中使用组件

<sofar-picker
  :visable.sync="pickerVisable"
  :defaultDate="defaultDate"
  :minYear="1990"
  themeColor="#10BE9D"
  startText="开始时间"
  endText="结束时间"
  @confirm="confirm">
</sofar-picker>

Props 参数说明

参数名 类型 默认值 说明
visable Boolean false 日期选择控件的显示/隐藏,注意使用.sync修饰符(true: 显示; false: 隐藏)
defaultDate Array [] 默认预设值
minYear Number 1990 最小年份
themeColor String #10BE9D 选择框操作栏部分字体颜色
startText String 开始时间 日期范围起始处文本
endText String 结束时间 日期范围结束处文本

Events 事件说明

事件名 说明 返回值
@confirm 点击确定按钮,返回当前选择的值 Array数组类型

Demo 代码示例

<template>
  <view class="content">
    <sofar-picker
      :visable.sync="pickerVisable"
      :defaultDate="defaultDate"
      @confirm="confirm">
    </sofar-picker>
  </view>
</template>

<script>
  import sofarPicker from '@/components/sofar-picker/sofar-picker.vue'
  export default {
    components: {
      sofarPicker
    },
    data() {
      return {
        pickerVisable: false,
        defaultDate: ['2020.1', '至今'],
        dateValue: []
      }
    },
    methods: {
      // 打开日期选择框
      openPicker() {
        this.pickerVisable = true
      },
      // 点击确定按钮,返回当前选择的值
      confirm(date) {
        this.dateValue = date
      }
    }
  }
</script>

<style>
  .content{
    width: 100%;
    height: 100%;
  }
</style>

uni-sofar-picker's People

Contributors

jamyking avatar

Stargazers

 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.