我正在格式化一个日期,没有momentjs或任何其他库,只是纯JS.我想知道是否有办法用ES6简化这一点
let currentDate = new Date();
const videosInformation = {
time: currentDate.getHours() + ':' + currentDate.getMinutes(),
date: (currentDate.getMonth() + 1) + '/' + currentDate.getDate() + '/' + currentDate.getFullYear(),
gameId: Math.floor((Math.random() * 5000) + 1)
};
Run Code Online (Sandbox Code Playgroud)
我在DOM中看到你使用类似的东西 renderSomething={`something: ${someObj}`}
所以你不必这样做 renderSomething={"something: " + {someObj}}
有什么我应该用来做那种格式?