当前位置:网站首页>V-inline-date, similar to Ctrip, flying pig, time selection with price
V-inline-date, similar to Ctrip, flying pig, time selection with price
2022-06-13 01:23:00 【Durian is not delicious】
v-inline-date
install
npm i -S v-inline-date
Source code
Use
Be careful , Use v-inline-date Make sure the project is installed momentjs
// main.js
import vInlineDate from "v-inline-date";
import 'v-inline-date/v-inline-date/v-inline-date.css'
Vue.use(vInlineDate)
<template>
<div>
<v-inline-date startDate="2021-07-07"endDate="2022-07-08"></v-inline-date>
</div>
</template>
Set the time range of the optional rule
<v-inline-date startDate="2021-07-07" endDate="2022-07-08" ></v-inline-date>
Set the selected time
<v-inline-date startDate="2021-07-07" endDate="2022-07-08" current="2021-07-10">
</v-inline-date>
Choose a single time or a time interval
Single time
<v-inline-date startDate="2021-07-07" endDate="2022-07-08" current="2021-07-10" :dateType="0" >
</v-inline-date>

Time interval
<v-inline-date startDate="2021-07-08" endDate="2022-07-09" :current="['2021-07-09','2021-07-11']" :dateType="1" >
</v-inline-date>
<!-- Add description -->
<v-inline-date startDate="2021-07-08" endDate="2022-07-09" :current="[{date:'2021-07-09',str:' To stay in '},{date:'2021-07-11',str:' Leave '}]" :dateType="1" >
</v-inline-date>


Time tagging
<v-inline-date startDate="2021-07-07" endDate="2022-07-08" current="2021-07-19" :dateJson="dateJson" >
</v-inline-date>
<script> data(){
return{
dataJson:[ {
date: '2021-07-14',price: "100",discount: " fold ",rest1: " Cease ",run: " run ",}, {
date: '2021-07-19',rest: " Cease ",}, {
date: '2021-07-26',fly: " fly ",} ] } } </script>

event selectDate
<v-inline-date @selectDate="selectDateEvent"></v-inline-date>
<script> methods:{
selectDateEvent(e){
console.log(e); // dateType by 0 When ,e:{...} // dateType by 1 When ,e:[{...},{...}] } } </script>
Be careful ,
If you use v-show Exhibition v-inline-date Words , In the open v-inline-date Called when this.$refs.selectdate.init() that will do
<div @click="openDate1">vif open </div>
<div class="picker" v-if="dateIsShow1">
<v-inline-date :current="current"></v-inline-date>
</div>
<div @click="openDate2">vshow open </div>
<div class="picker" v-show="dateIsShow2">
<v-inline-date ref="selectdate" :current="current"></v-inline-date>
</div>
<script> methods:{
// v-if open openDate1(){
this.dateIsShow1 = true; }, // v-show open openDate2(){
this.dateIsShow1 = true; this.$refs.selectdate.init(); } } </script>
explain
attribute
| Property name | describe | The default value is |
|---|---|---|
| startDate | The start time of the optional interval | moment().format(‘YYYY-MM-DD’) Today |
| endDate | The end time of the optional interval | moment().add(1,‘year’).format(‘YYYY-MM-DD’) That is, from today on, it will be pushed back for one year |
| dateType | 0: Only one time can be selected , 1: You can choose a time interval | 0 |
| current | Currently selected time , When dateType=1 When current Is a length of 2 Array of | nothing |
| dateJson | Tag a date , for example ( false , Cease , fold ) | nothing |
event
| Event name | describe | event |
|---|---|---|
| selectDate | The selected time | dateType by 0 When , Return an object dateType by 1 When , Returns a length of 2 Array of |
example
<v-inline-date ref="selectdate" :startDate="startDate" :endDate="endDate" :current="current" :dateJson="dateJson" :dateType="dateType" @selectDate="selectDateEvent" ></v-inline-date>
<script> import vInlineDate from "@/components/v-inline-date/v-inline-date.vue"; import moment from 'moment'; export default {
components: {
vInlineDate}, data() {
return {
startDate: moment().format('YYYY-MM-DD'), // The start time of the time range endDate: moment().add(1,'year').format('YYYY-MM-DD'), // The end time of the time range dateType:0, // 0: Only one time can be selected ,1: You can choose two times , Default 0 current: '2021-07-09', // The currently selected time /* current: ['2021-07-08','2021-07-12'], // dateType by 1 Array is supported when current: [ {date:'2021-07-08',str:' To stay in '}, {date:'2021-07-12',str:' Leave '}, ], // dateType by 1 Array is supported when , And the text on the date can be configured */ dateJson:[ // Add a symbol to a date {
date: moment().add(6,'day').format('YYYY-MM-DD'),price: "100",discount: " fold ",rest1: " Cease ",run: " run ",}, {
date: moment().add(11,'day').format('YYYY-MM-DD'),rest: " Cease ",}, ] }; }, } </script>



Add words to the price , Price , Labels etc. , Pictured

边栏推荐
- [Latex] 插入圖片
- leetcode. 151. flip the words in the string
- Thread code learning notes
- Alexnet实现Caltech101数据集图像分类(pytorch实现)
- 论文笔记:STMARL: A Spatio-Temporal Multi-AgentReinforcement Learning Approach for Cooperative Traffic
- Vector|hdu-4841 round table questions
- Golang context (context summary)
- Traditional machine learning classification model predicts the rise and fall of stock prices under more than 40 indicators
- ES6解构赋值
- Differences among bio, NiO and AIO
猜你喜欢

Sonarqube local installation

5G工业网关在煤矿行业的应用优势

Leetcode question brushing 02 linked list operation

How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of DBCD, ROC, vroc, Cr and psy index strategy income

项目实训(十七)---个人工作总结

Memory learning book reference

FLIP动画实现思路

Go JWT learning summary

Create a simple game interface using pyGame

Pipeline pipeline project construction
随机推荐
Leetcode-9-palindromes (simple)
DFS and BFS notes (II): depth first search (implemented in C language)
Wikipedia User Guide
Most elements leetcode
Introduction to convolutional neural network
leetode. 242. valid Letter heteronyms
Stmarl: a spatio temporal multi agentreinforcement learning approach for cooperative traffic
【斯坦福计网CS144项目】Lab1: StreamReassembler
[Latex] 插入圖片
【斯坦福計網CS144項目】Lab1: StreamReassembler
Traditional machine learning classification model predicts the rise and fall of stock prices under more than 40 indicators
My crawler learning notes
MySQL performance analysis - explain
Alexnet implements image classification of caltech101 dataset (pytorch Implementation)
Answer to matrix theory of Nanjing University of Aeronautics and Astronautics
Pysmb usage
spiral matrix visit Search a 2D Matrix
FSOs forest simulation optimization model learning notes
关于#数据库#的问题,如何解决?
Golang context (context summary)