In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how Mini Program uses wxs to solve the problem of wxml retaining 2 decimal places". In daily operation, I believe many people have doubts about how Mini Program uses wxs to solve the problem of wxml retaining 2 decimal places. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for everyone to answer the doubt of "how Mini Program uses wxs to solve the problem of wxml retaining 2 decimal places". Next, please follow the editor to study!
1. Spillover performance
You can see from the figure that the number exceeds a very long length. The code looks like this. Why did it appear at 0.35? Or do some complementary calculations appear? 0.34 will not.
0.41 will also appear, as if the result of the binary operation.
Data: {price:0.01, num:35}
The wxml file is just a result of dealing with one another.
{{price*num}}
two。 Add a constrained 2-decimal operation to the wxml file
Create a method in the wxml file and use the problem of keeping 2 decimal places directly when you call it. Create a wxs module, look at the following code, and add the corresponding processing method to the module.
{{we.toFixed (price*num)}} var toFixed = function (value) {return value.toFixed (2);} module.exports = {toFixed: toFixed}
After this method, the operation of Mini Program can be retained to 2 decimal places.
This is the end of the study on "how Mini Program uses wxs to solve the problem of keeping 2 decimal places in wxml". I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.