美文网首页微信小程序开发
wepy版本简单的时间日期选择

wepy版本简单的时间日期选择

作者: 泛酸的桂花酒 | 来源:发表于2019-01-05 11:11 被阅读5次

        <view>{{year}}年{{month}}月{{day}}日{{hour}}:{{minute}}

          indicator-style="height: 50px;"

          style="width: 100%; height: 300px;"

          value="{{value}}"

          bindchange="bindChange"

        >

            <view wx:for="{{years}}" style="line-height: 30px">{{item}}年

            <view wx:for="{{months}}" style="line-height: 30px">{{item}}月

          <view wx:for="{{days}}" style="line-height: 30px">{{item}}日

            <view wx:for="{{hours}}" style="line-height: 30px">{{item}}时

            <view wx:for="{{minutes}}" style="line-height: 30px">{{item}}分

      import wepyfrom 'wepy'

      const date =new Date()

    const years = []

    const months = []

    const days = []

    const hours = []

    const minutes = []

    for (let i =1990; i <= date.getFullYear(); i++) {

    years.push(i)

    }

    for (let i =1; i <=12; i++) {

    months.push(i)

    }

    for (let i =1; i <=31; i++) {

    days.push(i)

    }

    for (let i =1; i <=24; i++) {

    hours.push(i)

    }

    for (let i =1; i <=60; i++) {

    minutes.push(i)

    }

    export default class noticextends wepy.page {

    data = {

    years,

          year: date.getFullYear(),

          months,

          month:2,

          days,

          hour: date.getHours(),

          minute: date.getMinutes(),

          hours,

          minutes,

          day:2,

          value: [9999, 1, 1]

    }

    methods = {

    bindChange(e) {

    const val = e.detail.value

            let that =this

            this.year = that.data.years[val[0]]

    this.month = that.data.months[val[1]]

    this.day = that.data.days[val[2]]

    this.$apply()

    }

    }

    }

    相关文章

      网友评论

        本文标题:wepy版本简单的时间日期选择

        本文链接:https://www.haomeiwen.com/subject/cudrrqtx.html