vue.js城市选择框组件_响应式Vue.js日期选择器组件

vue.js城市选择框组件

TRVLPicker (TRVLPicker)

TRVLPicker is a responsive Vue.js datepicker component. From mobile to desktop it has a full-screen vertical layout, a single month layout, a double month layout, and a triple month layout.

TRVLPicker是一个响应式Vue.js日期选择器组件。 从移动设备到台式机,它具有全屏垂直布局,单月布局,双月布局和三月布局。

安装 (Install)

npm install @trvl/picker
import TRVLPicker from '@trvl/picker'

export default {
    // …
    components: {
        TRVLPicker,
    },
    // …
}

用法 (Usage)

基本的 (Basic)

In its most basic form, TRVLPicker only requires the checkin and checkout props. Both should be a Date object and have a sync modifier:

在最基本的形式中,TRVLPicker仅需要checkincheckout道具。 两者都应为Date对象并具有sync修饰符

<template>
    <TRVLPicker
        :checkin.sync="checkin"
        :checkout.sync="checkout"
    />
</template>

<script>
    import TRVLPicker from '@trvl/picker'

    export default {
        components: {
            TRVLPicker,
        },
        data() {
            return {
                checkin: new Date(2019, 2, 13),
                checkout: new Date(2019, 2, 15),
            }
        },
    }
</script>

高级 (Advanced)

To ensure a correct positioning of the datepicker in the full-screen layout it makes use of a Portal. Although not required, it is recommended to place a Portal target element outside your Vue app:

为了确保日期选择器在全屏布局中的正确位置,它使用Portal 。 尽管不是必需的,但建议将Portal目标元素放置在Vue应用程序外部:

<body>
    <div id="app">
        …
    </div>

    <div id="portal"></div>
</body>

道具 (Props)

PropTypeDefaultDescription
breakpointSingleNumber580Point at which the layout goes to a single month layout
breakpointDoubleNumber740Point at which the layout goes to a double month layout
breakpointTripleNumber0 (disabled)Point at which the layout goes to a triple month layout
checkinDateCheck-in date
checkoutDateCheck-out date
maxDateDatenew Date() + 1 yearLast possible check-out date
maxStayNumber30Maximum date range in days
minDateDatenew Date()First posssible check-in date
portalStringportalThe ID of the portal
Struts 类型 默认 描述
breakpointSingle 580 布局转到单月布局的位置
breakpointDouble 740 布局转到双月布局的位置
breakpointTriple 0 (禁用) 布局转到三个月布局的位置
checkin 日期 登记日期
checkout 日期 离开日期
maxDate 日期 new Date() + 1年 最后可能的退房日期
maxStay 30 最大日期范围(天)
minDate 日期 new Date() 第一次可能的入住日期
portal portal 门户的ID

插槽 (Slots)

All slots are optional, but the checkin and checkout slots are highly recommended so as to customize their appearance.

所有插槽都是可选的,但强烈建议checkincheckout插槽以自定义外观。

报到 (Check-in)

The template used for the check-in button.

用于签入按钮的模板。

<template slot="checkin" slot-scope="{ isActive, value }">
    <div :class="{ active: isActive }">
        <label for="checkin">Check-in</label>
        <input id="checkin" type="text" :value="value">
    </div>
</template>

The following data is available in the slot-scope:

slot-scope提供以下数据:

DataTypeDescription
isActiveBooleanWhether the check-in input is active
valueDateThe raw check-in value
数据 类型 描述
isActive 布尔型 值机输入是否处于活动状态
value 日期 原始值机值
退房 (Check-out)

The template used for the check-out button.

用于签出按钮的模板。

<template slot="checkout" slot-scope="{ isActive, value }">
    <div :class="{ active: isActive }">
        <label for="checkout">Check-in</label>
        <input id="checkout" type="text" :value="value">
    </div>
</template>

The following data is available in the slot-scope:

slot-scope提供以下数据:

DataTypeDescription
isActiveBooleanWhether the check-out input is active
valueDateThe raw check-out value
数据 类型 描述
isActive 布尔型 结帐输入是否处于活动状态
value 日期 原始结帐值
(Close)

The template used for the close button in the vertical layout.

垂直布局中用于关闭按钮的模板。

<template slot="close">
    <icon name="close" />
</template>
下一个 (Next)

The template used for the navigation button to go to the next month.

用于导航按钮的模板转到下个月。

<template slot="next">
    <icon name="next" />
</template>
以前 (Previous)

The template used for the navigation button to go to the previous month.

用于导航按钮的模板可以转到上个月。

<template slot="previous">
    <icon name="previous" />
</template>

方法 (Methods)

By adding a ref to the datepicker a couple of methods can be accessed:

通过将ref添加到日期选择器,可以访问以下两种方法:

<template>
    <TRVLPicker
        ref="picker"
        …
    />
</template>

<script>
    export default {
        mounted() {
            this.$refs.picker.callMethod()
        },
    }
</script>
MethodParametersDescription
closeClose the datepicker
opencheckin | checkoutOpen the datepicker on the given input (defaults to checkin)
方法 参量 描述
close 关闭日期选择器
open checkin | checkout 在给定的输入上打开日期选择器(默认为checkin )

大事记 (Events)

EventDescription
closeThe datepicker is closed
openThe datepicker is opened
事件 描述
close 日期选择器已关闭
open 日期选择器已打开

贡献 (Contributing)

# Project setup
npm install

# Compiles and hot-reloads for development
npm run serve

# Compiles and minifies for production
npm run build

# Lints and fixes files
npm run lint

# Runs unit tests
npm run test:unit

翻译自: https://vuejsexamples.com/a-responsive-vue-js-datepicker-component/

vue.js城市选择框组件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值