Element: DatePicker 日期选择器选择日期没有触发change事件

Created on 15 Feb 2017  ·  9Comments  ·  Source: ElemeFE/element

为什么我使用@change时,修改日期后没有触发相关的方法的调用,

<el-date-picker
              v-model="choosedTime.timeBeg"
              type="date"
              placeholder="选择日期下限"
              @change="chooseDate"
              :picker-options="pickerOptions0">
            </el-date-picker>
 methods: {
    chooseDate (val) {
      console.log(val)
    }
}
repro

Most helpful comment

@Create-Peace @lchreal6 改成@input就可以了,应该是文档有误

改成input 是触发了事件,也修改了数据,但datePicker组件显示还是原来的值

All 9 comments

我也遇到同样的问题 ,请问找到解决方法吗?

有问题请提供 demo

    这里是有的,链接和图片附上,请楼主去看下:http://element.eleme.io/#/zh-CN/

component/date-picker


[email protected]

发件人: lchreal6 notifications@github.com
发送时间: 2017-02-28 10:52
收件人: ElemeFE/element element@noreply.github.com
抄送: Subscribed subscribed@noreply.github.com
主题: Re: [ElemeFE/element] DatePicker 日期选择器选择日期没有触发change事件 (#2829)

我也遇到同样的问题 ,请问找到解决方法吗?


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/ElemeFE/element/issues/2829#issuecomment-282926383,
or mute
the thread
https://github.com/notifications/unsubscribe-auth/AYxWXf3diZzJM4kl3gaQxVxfnLKpxa-Dks5rg4vUgaJpZM4MBRJJ
.

问题出现在model上,我也遇到了,也说不太明白,这种情况是model

@Create-Peace @lchreal6 改成@input就可以了,应该是文档有误

@Create-Peace @lchreal6 改成@input就可以了,应该是文档有误

改成input 是触发了事件,也修改了数据,但datePicker组件显示还是原来的值

@Create-Peace @lchreal6 改成@input就可以了,应该是文档有误

改成input 是触发了事件,也修改了数据,但datePicker组件显示还是原来的值

遇到了一样的问题
正常操作可以提交,只是页面没有渲染正确的时间值

有问题请提供 demo

<el-date-picker
    class="pull-width"
    v-model="addTime"
    type="datetimerange"
    align="right"
    :start-placeholder="$t('common.startTime')"
    :end-placeholder="$t('common.endTime')"
    format="yyyy-MM-dd HH:mm:ss"
    value-format="timestamp"
    :pickerOptions="pickerOptions"
    @input="changeDate"
    :default-time="['00:00:00', '23:59:59']"
>
</el-date-picker>
// 修改状态的时候 addTime有默认值
addTime: [1581267600000, 1581958799000]
// 重新渲染 addTime 能正确赋值
->
然后 重新选择时间,组件的值不能正确渲染(还是原来的值)
但是提交的时候,上传值是正确的

      changeDate(val){
            // this.addTime = val;
            this.$set(this,'addTime',val)
            console.log(val,'val',this.addTime)
        }



@Create-Peace @lchreal6 改成@input就可以了,应该是文档有误

改成input 是触发了事件,也修改了数据,但datePicker组件显示还是原来的值

不能传入obj 对象 只能固定的帮一个数组值

ruleFormTimes:[0,0]

                      <el-date-picker
                        class="pull-width"
                        v-model="ruleFormTimes"
                        type="datetimerange"
                        align="right"
                        :start-placeholder="$t('common.startTime')"
                        :end-placeholder="$t('common.endTime')"
                        format="yyyy-MM-dd HH:mm:ss"
                        value-format="timestamp"
                        :pickerOptions="pickerOptions"
                        :default-time="['00:00:00', '23:59:59']"
                    >
                    </el-date-picker>
Was this page helpful?
0 / 5 - 0 ratings