将整数转换为此格式120M59
香港专业教育学院在网上看,搜索和问,但是没有人能回答我的问题,我需要格式化整个数字:12059看起来像120m59。 Ive尝试了MONT.JS进行操作,然后我遇到了错误。 typeError:MONM__WEBPACK_IMPORTED_MODULE_1 ___ DEFAULT.A.DURATION(...)。格式不是函数
如果我像SO data.total一样? Moment.Duration(Data.Total,'seconds')。格式('m [min] s [sec]'):'0'
有人可以帮忙吗?
Ive looked online and searched and asked but no one can answer my question I need to format a whole number Eg: 12059 to look like this 120m59s. Ive tried with moment.js to do it and Im getting an error.TypeError: moment__WEBPACK_IMPORTED_MODULE_1___default.a.duration(...).format is not a function
if I do it like so data.total ? moment.duration(data.total, 'seconds').format('m [min] s [sec]') : '0'
Could someone please help ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其弄清楚 -
moment.utc(Moment.Duration(data.Total,'seconds')。asmilliseconds())。格式('H [H] m [m] m [m] s [s]')
>我花了一些挣扎,花了几头发,但我听说秃顶是新事物。
figured it out -
moment.utc(moment.duration(data.total, 'seconds').asMilliseconds()).format('h[h]m[m]s[s]')
Took me a few struggles and costed a handful of hairs but I hear balding is the new thing.