Element two basic time selection boxes set (start-end) time range

1. Binding element own attributes : picker-pitions

               :picker-options="start_date"

                :picker-options="end_date"

2. Write the time limit for return. If the current selector time time.getTime() is greater than the start (end) time, the time before or after it cannot be selected. Note: The following code is written in return in data! ! (element provides a fixed format for this attribute)

3. Code

        

start_date: {

        disabledDate(time) {

          if(that.value2 !== '') {

            let value2 = Date.parse(that.value2)

            return time.getTime() > value2

          } else {

            return false

          }

        }

      },

      end_date: {

        disabledDate(time) {

          if(that.value1 !== '') {

            let value1 = Date.parse(that.value1)

            return time.getTime() < value1

          } else {

            return false

          }

        }

      },

4. What if there is an interval of x days? 

        Take an interval of 7 days as an example: -1 when counting milliseconds at an interval of x days

 

Guess you like

Origin blog.csdn.net/weixin_62355341/article/details/123623316