mouth和day不到两位时在前补0,即2021-7-31 ->2021-07-31 new Date().toString().padStart(2,0); padStart()一共接受两个参数,第一个参数用来指定字符串的最小长度,第二个参数是用来补全的字符串。 更多请看:介绍