解决方法:把'-'转成'/',
date.replace(/\-/g,'/'); // 格式化日期 const formatDate = (dt) => { let date = new Date(dt.replace(/-/g,"/")); let y = date.getFullYear(); let m = date.getMonth() + 1; m = m < 10 ? ('0' + m) : m; let d = date.getDate(); d = d < 10 ? ('0' + d) : d; return y + '-'+ m +'-' + d; };