In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces "how to click on the control to modify the style". In the daily operation, I believe that many people have doubts about how to click on the control to modify the style by WeChat Mini Programs. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "how to click on the control to modify the style" by WeChat Mini Programs. Next, please follow the editor to study!
WeChat Mini Programs clicks the control to modify the style example in detail.
Now you need to implement the click control to modify the style in WeChat Mini Programs, as follows:
Direct manipulation of dom is not supported in WeChat Mini Programs. To achieve this effect, we need to set up data, and then use the two-way binding of data and interface to achieve it.
Step 1: define clicked and unclicked styles in wxss as follows:
.service _ selection .is _ checked {border: 1px solid # FE0002; color: # FE0002; background: # fff;} .service _ selection. Normal {border: none; color: # 333; background: # F0F1EC;}
Step 2: set a flag in data in the js file, calling it isChecked, the default isChecked==false. As follows:
Data: {isChecked: false}
Step 3: bind the click event in the wxml file
Implement this method in the js file and click on it to set the isChecked==true. As follows:
ServiceSelection () {this.setData ({isChecked:true})}
Step 4: still bind the data in the wxml file:
The point is that this code
{{isChecked?'is_checked':'normal'}} "
This is a ternary operator. When isChecked==true, add the style of is_checked to class, and use the style of normal when it is flase. The implementation of this is similar to the syntax for php control style class names.
At this point, the study on "how to click on the control to modify the style of WeChat Mini Programs" 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.