vue日期选择组件_一个Vue组件,为波斯开发人员提供日期选择器

vue日期选择组件

Vue波斯日期选择器 (vue persian datepicker)

This is a Jalali date picker component for Vue.

这是Vue的Jalali日期选择器组件。

通用模块定义(UMD) (Universal Module Definition(UMD))

In order to use datepicker without node package manager include these scripts and style sheet ( I recommend using unpkg ):

为了在没有节点包管理器的情况下使用datepicker,请包括以下脚本和样式表(我建议使用unpkg):

<link href="https://unpkg.com/vue2-persian-datepicker/dist/vue2-persian-datepicker.css" rel="stylesheet"></script>
<script type=text/javascript src="https://unpkg.com/vue"></script>
<script type=text/javascript src="https://unpkg.com/vue2-persian-datepicker/dist/vue2-persian-datepicker.js"></script>

Then register the component :

然后注册组件:

Vue.component('pdatepicker', PDatePicker.PDatePicker);

NPM (NPM)

$ npm install vue2-persian-datepicker

Then register the component:

然后注册组件:

import Vue from 'vue'
import PDatePicker from 'vue2-persian-datepicker'
Vue.component('pdatepicker', PDatePicker)

用法 (Usage)

After registering the component you can use it in your markup:

注册组件后,您可以在标记中使用它:

<pdatepicker></pdatepicker>

基本用法 (Basic usage)

In most cases you use pdatepicker to provide a persian date picker for your users to pick a date from. So, you need a way to get selected date. You can easily achieve this by syncing a variable.

在大多数情况下,您可以使用pdatepicker提供波斯语日期选择器,以便用户从中选择日期。 因此,您需要一种获取选定日期的方法。 您可以通过同步变量轻松实现此目的。

This is pretty much what you have to do in order to get selected date or display a date to a user:

这几乎是您要获取选定日期或向用户显示日期所要做的事情:

<pdatepicker v-model="date"></pdatepicker>
export default{
    data(){
        return {
            date : '1396/6/8'
        };
    }
}

物产 (Properties)

PropertyTypeDefaultDescription
placeholderStringیک تاریخ را انتخاب کنیدPlace holder of input
header-colorColor'white'Header text color
header-background-colorColor'#137e95'Header background color
hover-day-back-colorColor'#137e95'Background color when mouse hovers an element
chosen-day-back-colorColor'#137e95'Background color for chosen day
dialog-color'black'Color Dialog text color
dialog-background-colorColor'#fafafa'Dialog background color
minimum-yearNumber1300Minimum selectable year for user
maximum-yearNumber1350Maximum selectable year for user
nameString''Name element for normal http form submit
requiredBooleanfalsevalue of HTML required attribute
idString''value of input's id attribute
input-classString''css class for input element
dialog classString''css class for dialog element
wrapper-classString''css class wrapper element of component
input-disabledBooleantruefor responsive reasons input is disabled by default but you can enable it if you need to.
initial-viewString'day'Initial view of component (month or day)
inline-modeBooleanfalseinline mode
format-dateString'yyyy/MM/dd'formats output date. order of date element should not change
open-transition-animationString'slide-fade'you can specify a transition for opening and closing dialog.
persianDigitsBooleantruewhether to use persian or english digits
availableDatesBooleanfalseIf you want limit user to certain range of dates
availableDateStartString1300/01/01In case of setting availableDates to true, use this to set start date
availableDateEndString1450/12/29In case of setting availableDates to true, use this to set end date
disableDatesBeforeTodayBooleanfalseThis will disable all dates before today
modal-modeBooleanfalseThis will make dialog modal.
modal-open-transition-animationString'scale-fade'you can specify a transition for opening and closing dialog in modal mode.
属性 类型 默认 描述
占位符 تاریخراانتخابکنید 输入的占位符
标题颜色 颜色 '白色' 标题文字颜色
标题背景颜色 颜色 '#137e95' 标头背景色
悬停一天回来的颜色 颜色 '#137e95' 鼠标悬停元素时的背景色
选择的一天回来的颜色 颜色 '#137e95' 所选日期的背景色
对话框颜色 '黑色' 颜色对话框文字颜色
对话框背景色 颜色 '#fafafa' 对话框背景色
最小年 1300 用户的最小可选年份
最长年份 1350 用户的最大可选年份
名称 '' 正常http表单提交的名称元素
需要 布尔型 HTML必填属性的值
ID '' 输入的id属性的值
输入类 '' 输入元素CSS类
对话课 '' 对话框元素CSS类
包装类 '' 组件的css类包装器元素
禁用输入 布尔型 真正 出于响应的原因,默认情况下禁用输入,但是您可以根据需要启用它。
初步观点 '天' 组件的初始视图(月或日)
内联模式 布尔型 内联模式
格式日期 'yyyy / MM / dd' 格式化输出日期。 日期顺序元素不应更改
开放过渡动画 “幻灯片淡入淡出” 您可以指定用于打开和关闭对话框的过渡。
波斯数字 布尔型 真正 使用波斯数字还是英文数字
availableDates 布尔型 如果要将用户限制为一定日期范围
availableDateStart 1300/01/01 如果将availableDates设置为true,请使用此设置开始日期
availableDateEnd 1450/12/29 如果将availableDates设置为true,请使用此设置结束日期
disableDatesBeforeToday 布尔型 这将禁用今天之前的所有日期
模态模式 布尔型 这将使对话框成为模态。
模态开放过渡动画 “淡入淡出” 您可以指定模式模式下打开和关闭对话框的过渡。

大事记 (Events)

eventParametersdescription
openedDate StringThe picker's dialog is opened
closedDate StringThe picker's dialog is closed
monthChangedDate StringMonth page has changed
yearChangedDate StringYear page has changed
selectedDate ObjectA date has been selected
inputDate StringInput changed
事件 参量 描述
开了 日期字串 选择器的对话框打开
关闭 日期字串 选择器的对话框关闭
monthChanged 日期字串 月页已更改
yearChanged 日期字串 年份页面已更改
已选 日期对象 选择了一个日期
输入 日期字串 输入已更改

获取选择的日期 (Get selected date)

Using v-model you can sync a value to selected date. Or, you can listen to selected event and get selected date.

使用v模型,您可以将值同步到所选日期。 或者,您可以收听选定的事件并获得选定的日期。

日期格式 (Date formatting)

There are several ways you can print selected date on user input. Keep in mind that you have to keep order of date (year/month/date)

您可以通过多种方式在用户输入上打印所选日期。 请记住,您必须保持日期顺序(年/月/日)

tokendescexample
dday3
ddday with 0 prefixed day03
Mmonth number4
MMmonth with 0 prefix day04
MMMmonth nameفروردین
yytwo digits year96
yyyyfour digits year1396
代币 描述
d 3
dd 带0前缀的日期的一天 03
中号 月数 4
MM 带有0个前缀天的月份 04
MMM 月份名称 فروردین
y 两位数年份 96
yyyy 四位数年份 1396

翻译自: https://vuejsexamples.com/a-vue-component-that-provides-datepicker-for-persian-developers/

vue日期选择组件

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值