In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how WeChat Mini Programs uses wxs to calculate the data". In daily operation, I believe many people have doubts about how WeChat Mini Programs uses wxs to calculate the data. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how WeChat Mini Programs uses wxs to calculate the data". Next, please follow the editor to study!
Wxs is often used for data processing. WXS code can be written in tags in wxml files, or in files with the suffix .wxs.
A little bit of calculation is often needed for the data that has been obtained, such as dividing two numbers and taking only two decimal places.
Wxs is often used for data processing. WXS code can be written in tags in wxml files, or in files with the suffix .wxs. Case one: writing in the wxml used applies to the module definition step 1 used only in this file. Define this module to write event handlers and expose them.
Var getEvery = function (totle,each) {
Var eachPrice= (totle/each) .tofixed (2)
Return eachPrice;}
Module.exports.getEvery = getEvery
This code is written in the wxml file where each .wxs file and tag is a separate module. Each module has its own independent scope. That is, variables and functions defined in one module are private by default and are not visible to other modules. If a module wants to expose its internal private variables and functions, it can only be implemented through module.exports.
Step 2 is used in wxml: module name. Method name (parameter 1, parameter 2)
Parameter is the one in page.js
Array1?\ 'true\':\'}} > converted single: ¥
{
{
M1.getEvery (goods.retailPriceJia,goods.childNum)
}
}
That's it.
In case 2, defining wxs outside the reference file does not depend on the runtime version of the underlying library and can be run in all versions of Mini Program. So you don't need to care about the version of step 1.wxs file in Wechat developer tool, right-click to create .wxs file and write WXS script directly in it.
Step 2 single file definitions can expose variable names and functions, one or more
Var filters = {
ToFix: function (value) {
Return value.toFixed (2) / / where 2 is reserved for two decimal places
}
}
Var filt = {
ToFix: function (value) {
Return value.toFixed (1)
/ / here 1 is reserved for 1 decimal place
}
}
Module.exports = {
ToFix: filters.toFix, toFixs: filt.toFix
}
The .wxs file can be referenced by tags in other .wxs files or in WXML.
Step 3 is used on other pages
; for
{
{
Filt.toFixs (item.retailPriceJia)
}
}
/ Market price: ¥{{filt.toFixs (item.retailPrice)}}
At this point, the study on "how WeChat Mini Programs uses wxs to calculate the data" is over. I hope to be able to solve everyone's 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.