在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ typesctipt 報(bào)錯(cuò) Property 'format' does not

typesctipt 報(bào)錯(cuò) Property 'format' does not exist on type 'Date'.

  public getAllDay (begin: any, end: any) {
    const dateAllArr = new Array();
    const ab = begin.split('-');
    const ae = end.split('-');
    const db = new Date();
    db.setUTCFullYear(ab[0], ab[1] - 1, ab[2]);
    const de = new Date();
    de.setUTCFullYear(ae[0], ae[1] - 1, ae[2]);
    const unixDb = db.getTime();
    const unixDe = de.getTime();
    for (let k = unixDb; k <= unixDe;) {
       dateAllArr.push((new Date(parseInt(k))).format().toString());
       k = k + 24 * 60 * 60 * 1000;
    }
    return dateAllArr;
  }

請(qǐng)問怎么解決

回答
編輯回答
純妹

Date類型上不存在format屬性啊。

2018年1月23日 01:31
編輯回答
涼心人

因?yàn)?format 這個(gè)方法不存在
https://developer.mozilla.org...

2018年7月12日 02:31
編輯回答
墻頭草

這段代碼從各個(gè)方面來(lái)說(shuō)錯(cuò)的不止一點(diǎn)點(diǎn)... 先把需求說(shuō)明清楚吧?
unixDb unixDe 這兩個(gè)值之間單位差 可以用ms計(jì)算
K以一天遞增?

format()在push函數(shù)后,即便Date有format方法也調(diào)用有問題??! Date是沒有format()方法的,
可以考慮自己拼接 或者使用toLocaleString()

2017年5月11日 22:49