uniapp橫向滾動選擇日期

2021-10-06 04:22:47 字數 3321 閱讀 6107

1.方法封裝 common.js

//獲取當前時間,格式yyyy-mm-dd hh:mm:ss

const getnowtime = time =>

// 格式化**號碼

const getphone = phone =>

//返回日期和週幾陣列

function weekdate() );

for (var i = 0; i < 10; i++) )

} // return daylist;

let length = daylist.length

let arrone = daylist[0]

let arrlast = daylist[length - 1]

let startdate = arrone.year.tostring() + '-' + arrone.month + '-' + arrone.day

let enddate = arrlast.year.tostring() + '-' + arrlast.month + '-' + arrlast.day

return

}function toweekday(weekday)

return '傳入未知引數';

}module.exports =

2.元件.vue

>

>

class

="box"

>

scroll-x

="true"

>

v-for

="(item, index) in daylist"

:key

="index"

>

class

="daytitle"

:class

="current == index ? 'select' : ''"

@click

="timeselectd(index)"

>

style="

display

: flex;

flex-direction

: column;

justify-content

: center;

width

: 100%;

height

: 100%;

">

>

}view

>

v-if

="index == 0"

style="

font-size

: 25upx;

">

今天view

>

v-else

style="

font-size

: 25upx;

">

星期}view

>

view

>

view

>

block

>

scroll-view

>

view

>

view

>

template

>

>

import vue from

'vue'

;import common from

'../../common/common.js'

;export

default;}

,onload()

, methods:}}

;script

>

scoped

>

.box

scroll-view

.daytitle

.select

style

>

效果圖

>

>

class

="box"

>

scroll-x

="true"

:scroll-left

="scrollleft"

@scroll

="scroll"

>

v-for

="(item, index) in daylist"

:key

="index"

>

class

="daytitle"

:class

="current == index ? 'select' : ''"

@click

="timeselectd(index)"

>

style="

display

: flex;

flex-direction

: column;

justify-content

: center;

width

: 100%;

height

: 100%;

">

>

}view

>

v-if

="index == 0"

style="

font-size

: 25upx;

">

今天view

>

v-else

style="

font-size

: 25upx;

">

星期}view

>

view

>

view

>

block

>

scroll-view

>

view

>

type

="default"

@click

="gotoday"

>

回到今天button

>

view

>

template

>

>

import vue from

'vue'

;import common from

'@/common/common.js'

;export

default;}

,onload()

, methods:

,scroll(e

),gotoday()

}};script

>

Android應用日期 選擇日期和時間

為了讓使用者能選擇日期和時間,android提供了日期 時間選擇器,分別是datepicker元件和timepicker元件。為了在程式中可以獲取使用者選擇的日期時間,還需要為datepicker元件和timepicker元件新增事件 1 在新建專案的布局檔案中,新增日期拾取器和時間拾取器。2 在主...

Js判斷選擇日期不能小於當前日期

需求 選擇日期不能大於當前日期 new date 出來的時間帶有小時分秒等,這樣造成比較當天日期時產生問題 可以alert看看 thu jul 12 2018 00 00 00 gmt 0800 中國標準時間 thu jul 12 2018 08 39 33 gmt 0800 中國標準時間 new ...

uniapp 日期外掛程式 日期時間選擇器

日期時間選擇器 datepicker 介紹一款高顏值 多場景的日期時間選擇器,提供自定義顏色 格式 文案等。該外掛程式採用scss編譯,如遇到樣式 層級問題可以到原始碼修改。屬性說明 屬性型別 預設值說明 show boolean false 是否顯示 type string date 型別,可選值...