国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

datepicker/calendar(價格日歷|日歷|日期選擇器)

simpleapples / 2026人閱讀

摘要:基于事件操作的價格日歷,適用于端和移動端

基于事件操作的價格日歷,適用于PC端和移動端
https://github.com/Fi2zz/date...

FEATURES

Base on event

Easy to display data on html element by using data event

Support double views,flat view and single view

Disabled date can be selected as end date while using setData function

Support Multi selection

RUN DEMO
yarn dev or npm run dev 
OPTIONS
OPTION RERUIRED TYPE DESC DEFAULT VALUE
el YES string,HTMLElement Element or selector to mount DatePcker
startDate NO Date Start date of DatePicker new Date
endDate NO Date End date of DatePicker new Date() + 6 months
doubleSelect NO boolean Enable pick two dates false
limit NO number Limitation between two dates while doubleSelect is on
views NO number,string Display views of DatePicker auto,1,2
selection NO number Size of dates can be picked ,value must be not less than 2 1
NOTE
when `selection` is greater than 2, `bindData` and `doubleSelect` will be set to `false`,
and `option.limit` will be set the same as `selection`
API
   setDates([dates]:tuple);
   //Set  dates to DatePicker
   //dates accept  and 

   setLanguage(language:any);
   //set DatePicker"s language

   setData(callback)
   //set data to DatePicker
   //more detail see [USAGE]

   setDisabled({
        days?:Array[5],
        dates?:Array,
        from?:,
        to?:
    })
   //Set disabled dates to DataPicker
   //dates =>dates accept  and ,  all dates in [dates] will be disabled
   //days => days accept number of [0~6],   all days in [days] will be disabled
   //from => from accept  or , all dates after [from] date will be disabled,
   //        eg: from = 2018-3-31 => disabled from 2018-4-1  
   //to   => to accept  or  all dates before [to] date will be disabled,
   //        eg: to =2018-3-4 => all dates before 2018-3-5 will be disabled

   parse(formattedDate:string,dateFormat:string)
   //Transform date string into date object,return Date object
   //eg: formattedDate ="2018-3-4",format="YYYY-M-D" =>  new Date(2018,2,4)

   format(date:Date,format:string)
   //Transform date object into string,return string  
   //eg: date =new Date(),format="YYYY-MM-DD" => 2018-03-04

   on(event:string,fn:Function)
   //Event listener
   //eg: datePicker.on("event",(result)=>{
                //your logic
   //    })
USAGE
    //es module
    import DatePicker from "/dist/datepicker.esm.js"
    import "/dist/style.css"

    //cjs
    const DatePicker =require("/dist/datepicker.js");
    require("/dist/style.css");


    //umd
    
    



    const date = new Date();
    const dist = {
           year: date.getFullYear(),
           month: date.getMonth(),
           date: date.getDate()
    };

    const from = new Date(dist.year, dist.month, dist.date)
    const to = new Date(dist.year, dist.month + 9, 0);
    const currDate = new Date(dist.year, dist.month, dist.date);

    //setup DatePicker instance
    const app = new DatePicker({
            el: document.getElementById("datepicker"),
            endDate:to,
            startDate:from,
            limit: 7,
            format: "YYYY-M-D",
            doubleSelect: true,
            views: 1,
            selection:4 // if selection not less than 2, doubleSelect will be disabled,
                        //and `data` event and `setData` will not work
    });




    //`update` event fired by click on date cell and DatePicker init
    app.on("update", (result) => {
        // result contains two keys, `value` and `type`
        // value =>  selected dates
        // type  =>  two types => `init` and `selected`
        // place your logic  here
        //eg:
        // document.getElementById("dates").innerText = value
    });

    // `disabled`event fired by `setDisabled`
    app.on("disabled", (result) => {
        // result contains two keys, `dateList` and `nodeList`
        const {dateList, nodeList} = result;
        for (let n = 0; n < nodeList.length; n++) {
            let node = nodeList[n];
            if (dateList[node.getAttribute("data-date")]) {
                node.classList.add("disabled")
            }
        }
    });
    // "data" event fired by `setData`
    app.on("data", (result) => {
        //set HTML nodes states
        // result contains two keys, `data:any` and `nodeList:Array`
            const data = result.data;
            const nodeList = result.nodeList;
            for (let i = 0; i < nodeList.length; i++) {
                let node = nodeList[i];
                let date = node.getAttribute("data-date");
                if (date in data) {
                    if (!node.classList.contains("disabled")) {
                        let itemData = source[date];
                        if (itemData.highlight) {
                            addClass(node, "highlight")
                        }
                        let placeholder = node.querySelector(".placeholder");
                        placeholder.innerHTML = itemData.value
                    }

                } else {
                    addClass(node, "disabled")
                }
            }
        });

       //tuple type,accept  and 
       const selected=["2018-2-21",new Date()];
       //use `setDates` to set init dates to DatePicker instance
       app.setDates(selected);
       // use `setDisabled` to set specified date or day to disabled,
       // `setDisabled` accept an object => {dates,days},
       // dates,accept  and  
       // >days accept 0,1,2,3,4,5,6
       app.setDisabled({
                dates: [
                    "2018-2-18",
                    "2018-2-19",
                    "2018-2-22",
                    new Date
                ],
                days: [1, 5, 2, 6],
                from:new Date(2018,2,10)
                to:"2018-7-15"
            });

        // To display your data,like price info on date cell,
        // use `setData` to pass data to `DatePicker` instance
        // `setData` function will dispatch `data` event
        // setup a listener to handle it
       app.setData(() => {
                    const data ={};
                    /*data accept Object like
                     {
                       "2018-1-31":{/*your codes * },
                       "2018-2-21":123,
                        }
                    */
                    //your logic here


                    //return data when your logic done
                    return data
        });

       //set DatePicker"s language
       //language options
       const language={
                 days: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
                 months: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
                 year: ""
       };
       app.setLanguage(language)

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://m.specialneedsforspecialkids.com/yun/89726.html

相關文章

  • 移動端H5日歷組件,已廢棄不在維護

    摘要:默認可選回調函數,綁定業務數據。例如某天有日程,則會在對應日期上標識出一個小紅點或者其他標識,默認傳入數據格式必選回調函數,當你點擊或輕觸某日期后執行。 文檔維護者:孫尊路 喜歡的話,記得star 一下噢! 適用場景 該組件目前僅適用于移動端H5頁面展示,后期高級用法中會講述到如何基于日歷基類實現自定義模板傳入。(即:開發者只需要傳入自己的模板即可實現出自己的優美的日歷出來。) 本篇...

    Moxmi 評論0 收藏0
  • 怎樣實現一個datePicker日期選擇)組件

    摘要:百度前端技術學院上有一個任務,要實現一個日期選擇組件,本文由此而來看看需求組件默認一直呈顯示狀態通過某種方式選擇年月,選擇了年月后,日期列表做相應切換通過單擊某個具體的日期進行日期選擇組件初始化時,可配置可選日期的上下限。 百度前端技術學院上有一個任務,要實現一個日期選擇組件,本文由此而來~ 看看需求 組件默認一直呈顯示狀態 通過某種方式選擇年、月,選擇了年月后,日期列表做相應切換 ...

    layman 評論0 收藏0
  • 怎樣實現一個datePicker日期選擇)組件

    摘要:百度前端技術學院上有一個任務,要實現一個日期選擇組件,本文由此而來看看需求組件默認一直呈顯示狀態通過某種方式選擇年月,選擇了年月后,日期列表做相應切換通過單擊某個具體的日期進行日期選擇組件初始化時,可配置可選日期的上下限。 百度前端技術學院上有一個任務,要實現一個日期選擇組件,本文由此而來~ 看看需求 組件默認一直呈顯示狀態 通過某種方式選擇年、月,選擇了年月后,日期列表做相應切換 ...

    beanlam 評論0 收藏0
  • vue 手寫一個時間選擇

    摘要:實現代碼于文章末尾處構思頁面結構組件由輸入框和日歷面板組成,寫好頁面主體結構。輸入框點擊顯示或隱藏日歷面板方法改變布爾值控制日歷面板的顯示隱藏。同時,當組件銷毀時,也要及時清除該監聽器。 最近研究了 DatePicker 的實現原理后做了一個 vue 的 DatePicker 組件,今天帶大家一步一步實現 DatePicker 的 vue 組件。 原理 DatePicker 的原理是—...

    sf_wangchong 評論0 收藏0

發表評論

0條評論

simpleapples

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<