Git Product home page Git Product logo

vue-date's Introduction

vue-datepicker

datepicker component for Vue.js, already support Vue.js 2.x, the Vue.js 1.x version is on branch vue-1.x(not maintain).

Live Demo is here

Installation

npm install vue-date --save

Usage

use with single .vue file:

<template>
    <div>
        <datepicker v-model="date"></datepicker>
    </div>
</template>

<script>
    import datepicker from 'vue-date'
    export default {
        data() {
            return {
                date: '2016-10-16'
            }
        },
        components: { datepicker }
    }
</script>

use in browser:

//index.html
<html>
    <script src="path/to/vue.js"></script>
    <script src="path/to/index.js"></script>
    <body>
        <div id="app">
            <datepicker v-model="date"></datepicker>
        </div>
        <script>
            new Vue({
                el: '#app',
                data: {
                    date: '2016-10-16'
                },
                components: { datepicker }
            })
        </script>
    </body>
</html>

Props

language

Type: String
Default: en
Optional: en(English), zh-cn(Chinese), uk(Ukrainsk), es(Spanish)

The language type. Support en(English), zh-cn(Chinese), uk(Ukrainsk) and es(Spanish) now.

min

Type: String
Default: 1970-01-01

The minimum date.

//pass string
<datepicker v-model="start" min="2015-01-01"</datepicker>
//or pass variable
<datepicker v-model="start" :min="variable"></datepicker>

max

Type: String
Default: 3016-01-01

The maximum date. Usage is same of min.

range

Type: Boolean
Default: false

Use range mode or not. If pass true, the binding value should be an Array containg the range start and range end. eg. ['1970-01-01', '3016-01-01']

Licence

MIT

vue-date's People

Contributors

fvictorio avatar jcamilorm902 avatar showonne avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-date's Issues

console log Vue warn

on chrome console [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "value"
(found in component at ./src/components/datepicker.vue)

child component should emit event to change props value on che parent

能否做到支持SSR

做的项目需要用到服务器端渲染(SSR),但是vue-date里的windon会报错,能否升级版本到支持SSR

Errors after update

I am getting the following errors after I updated the module:

Uncaught TypeError: Cannot read property '0' of undefined
at VueComponent.eval (eval at (app.js:769), :1:10244)
at Array.func (eval at (app.js:1776), :454:26)
at MutationObserver.nextTickHandler (eval at (app.js:1776), :405:16)
(anonymous) @ index.js?6fa7:1
func @ vue.js?3de6:454
nextTickHandler @ vue.js?3de6:405

vue.js?3de6:2252 Uncaught TypeError: t._v is not a function
at Proxy.render (eval at (app.js:769), :1:22995)
at VueComponent.Vue._render (eval at (app.js:1776), :2240:22)
at VueComponent.eval (eval at (app.js:1776), :1695:21)
at Watcher.get (eval at (app.js:1776), :740:27)
at new Watcher (eval at (app.js:1776), :732:12)
at VueComponent.Vue._mount (eval at (app.js:1776), :1694:19)
at VueComponent.Vue$3.$mount (eval at (app.js:1776), :5592:15)
at VueComponent.Vue$3.$mount (eval at (app.js:1776), :7494:16)
at init (eval at (app.js:1776), :1978:11)
at createElm (eval at (app.js:1776), :3825:56)

This is the view:
<datepicker
range="event_date.range"
v-model="event_date.date"
@input="updateEventDate">

Language FR

Language 'fr' is not well supported
image

months : {
"original": [ "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ],
"abbr": [ "Jan", "Fév", "Mar", "Avr", "Mai", "Juin", "Juil", "Août", "Sep", "Oct", "Nov", "Déc" ]
},
days : [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" ]

Minor usability enhancements

Just added these lines of code:

  1. German translation:
    case 'de': return {0: 'So', 1: 'Mo', 2: 'Di', 3: 'Mi', 4: 'Do', 5: 'Fr', 6: 'Sa'}[item];

case 'de': return {1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Okt', 11: 'Nov', 12: 'Dez'}[item];

  1. Navigation over border of year:

prevMonthPreview() {
if (this.tmpMonth === 0) {
this.tmpMonth = 11;
this.tmpYear = this.tmpYear - 1;
} else {
this.tmpMonth = this.tmpMonth - 1;
}
},
nextMonthPreview() {
if (this.tmpMonth === 11) {
this.tmpMonth = 0;
this.tmpYear = this.tmpYear + 1;
} else {
this.tmpMonth = this.tmpMonth + 1;
}
}

  1. Clear (set back to default view)
    clear() {
    this.panelType = 'date';
    this.$emit('input', this.range ? ['', ''] : '');
    }

  2. not done yet: reset to selected:
    If you already picked a date or range and you open the datepicker and change the year/month and close it without to adopt that date and reopen it date and month still have the last selected values, it should be set back to init state on panelType = 'date' and the list should be the one where your date is visible

Best + thx for your work!
PJ

how to show the cancle button?

I am using 1.1.6.
the code
<datepicker v-model="taskCreateTimeMin" :language="'ch'"></datepicker>
I want to clear the value of input ,but no cancle button.`

切换年份后,日历日期与星期匹配不正确

当切换日历年份的时候,每月对应的日期和星期匹配不正确,比如切换到2016年12月1日时,匹配的星期为星期五(Fr),但其实应该是星期四(Th),看了源码发现是在298和299行 ----
298. let startDay = new Date(this.year, this.tmpMonth, 1).getDay()
299. let previousMongthLength = new Date(this.year, this.tmpMonth, 0).getDate()
获取当前选择的年份使用的是this.year ,修改为 this.tmpYear 即可。

Language ES

Language 'es' is not well supported:

image

Days: {0: Domingo, 1: Lunes, 2: Martes, 3: Miércoles, 4: Jueves, 5: Viernes, 6: Sábado}
You can change 'é' 'á' chars for 'e' and 'a' respectively

Months: {1: Enero, 2: Febrero, 3: Marzo, 4: Abril, 5: Mayo, 6: Junio, 7: Julio, 8: Agosto, 9: Septiembre, 10: Octubre, 11: Noviembre, 12: Diciembre}

Language and Format

Please can you add support to language "pt-br" and format "dd/mm/yyyy"/"dd-mm-yyyy" ?
pt-br: {1: 'Jan', 2: 'Fev', 3: 'Mar', 4: 'Abr', 5: 'Mai', 6: ' 7: 'Jul', 8: 'Ago', 9: 'Set', 10: 'Out', 11: 'Nov', 12: 'Dez'}

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.