Element: [Bug Report] 向表单Datetime Picker传入日期报错

Created on 13 Apr 2017  ·  4Comments  ·  Source: ElemeFE/element

Element UI version

1.2.8

OS/Browsers version

window10

Vue version

2.2.6

Steps to reproduce

传入2015-05-02 这样的日期

What is Expected?

在表单中能够验证成功,并正确提交

What is actually happening?

 warn]: Error in callback for watcher "displayValue": 
(found in <ElDatePicker>)
vue.esm.js?d2fe:1447 TypeError: value.getTime is not a function
    at Object.date [as validator] (eval at <anonymous> (http://localhost:8080/app.js:2638:1), <anonymous>:28:45)
    at eval (eval at <anonymous> (http://localhost:8080/app.js:2575:1), <anonymous>:232:12)
    at next (eval at <anonymous> (http://localhost:8080/app.js:840:1), <anonymous>:133:7)
    at asyncSerialArray (eval at <anonymous> (http://localhost:8080/app.js:840:1), <anonymous>:139:3)
    at eval (eval at <anonymous> (http://localhost:8080/app.js:840:1), <anonymous>:173:7)
    at Array.forEach (native)
    at asyncMap (eval at <anonymous> (http://localhost:8080/app.js:840:1), <anonymous>:170:14)
    at Schema.validate (eval at <anonymous> (http://localhost:8080/app.js:2575:1), <anonymous>:159:24)
    at VueComponent.validate (eval at <anonymous> (http://localhost:8080/app.js:2477:1), <anonymous>:15691:18)
    at VueComponent.boundFn [as validate] (eval at <anonymous> (http://localhost:8080/app.js:872:1), <anonymous>:125:14)

向表单中从数据库传入2017-05-02这样的日期,提交表单会报这样的错 , 验证类型是type:date , 从数据库拿到的是string类型 , 是这样的原因导致的吗 , 怎么解决呢

Most helpful comment

@CaraDelevingne 赋值的时候需要 new Date() 一下

All 4 comments

日期应该给 Date 类型的

请参照楼上的回复。

html是给的date类型
<el-date-picker type="date" placeholder="选择日期" v-model="sendArgs.InviteBeginTime" style="width: 100%;"></el-date-picker>

@CaraDelevingne 赋值的时候需要 new Date() 一下

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fscardua picture fscardua  ·  3Comments

gengxuelei picture gengxuelei  ·  3Comments

yubo111 picture yubo111  ·  3Comments

FranzSkuffka picture FranzSkuffka  ·  3Comments

dbskccc picture dbskccc  ·  3Comments