当前位置:网站首页>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

边栏推荐
- Thread code learning notes
- Matrix fast power
- leetcode. 349. intersection of two arrays
- Wal mechanism of MySQL
- [从零开始学习FPGA编程-21]:进阶篇 - 架构 - VerilogHDL编码规范
- 关于#数据库#的问题,如何解决?
- Traditional machine learning classification model predicts the rise and fall of stock prices under more than 40 indicators
- [Stanford Jiwang cs144 project] lab1: streamreassembler
- Characteristics of transactions - persistence (implementation principle)
- Tkinter library installation
猜你喜欢

spiral matrix visit Search a 2D Matrix

Traversal of binary tree - first order traversal, middle order traversal, and second order traversal

ES6 deconstruction assignment

How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic benefits of ASI, VR, arbr, DPO and trix indicators

HashSet underlying source code

Minimum spanning tree problem

Plusieurs catégories de tests logiciels sont claires à première vue

MySQL index

Common skills for quantitative investment - indicators Chapter 3: detailed explanation of RSI indicators, their code implementation and drawing

Leetcode question brushing 04 string
随机推荐
Tkinter library installation
redis
Continue when the condition is not asked, execute the parameter you compare
How to choose stocks? Which indicator strategy is reliable? Quantitative analysis and comparison of strategic returns of BBI, MTM, obv, CCI and priceosc indicators
Five classic articles worth reading (2)
[latex] insérer une image
Happy string
Application advantages of 5g industrial gateway in coal industry
Pytorch's leafnode understanding
Five classic articles worth reading
Leetcode question brushing 04 string
MySQL transaction
Lessons learned from the NLP part of the course "Baidu architects hands-on deep learning"
304. Merge two ordered arrays
论文笔记:STMARL: A Spatio-Temporal Multi-AgentReinforcement Learning Approach for Cooperative Traffic
[Stanford Jiwang cs144 project] lab1: streamreassembler
软件测试的几种分类,一看就明了
Downloading wiki corpus and aligning with multilingual wikis
切线与切平面
spiral matrix visit Search a 2D Matrix