Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does WeChat Mini Programs use button to control the variables of condition tags

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "how WeChat Mini Programs uses button to control the variables of condition tags". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Solution

Step one:

First open the Wechat public platform, copy a primary button button code to the development platform, and then bind it to an event named "bindfirst". (of course, this bindfirst event needs to be defined in js, which will be defined in the following steps.)

The code is as follows:

Click and change.

Step 2:

Create a text for if condition tags to control, while defining an empty quantity in the js.

Assign a judge variable to the definition of the if condition to true (if the if condition tag is true, it displays text, if it is false, it does not display text), and then change the value of text in the event bound by button.

The code is as follows:

Wxml code

Click to change {{text}}

Js code

Page ({data: {text: [], judge:true,}, onLoad: function () {}, bindfirst:function () {var s=this.data.judgethis.setData ({text: "you clicked on me")})

Step 3:

Get the running results.

Text appears when you click once, and text is closed when you click the second time, because bindfirst uses changing the values of judge to true and false to change text.

This is the end of the content of "how WeChat Mini Programs uses button to control the variables of condition tags". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report