Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在应用程序中有一个“周”变量:
Math.abs(var_weeks / ONE_WEEK);
它返回“37.3857142857143 周”
我怎样才能将此值减少到“37.3 周”?
我只需要在逗号后留下一个数字。谢谢!
要在逗号后留下一个数字,我做了下一个:
var weeks // it returns 5.123123 for example var weeksnum = weeks * 10; // it returns 51.23123 var weeksfinal = Math.round(weeksnum)/10; // it returns 512/10 - 51.2