Example of how a small program can dynamically control the opening and closing of a switch

高洛峰
Release: 2018-05-10 16:01:30
Original
6619 people have browsed it

Requirements:
In the process of developing small programs, we may encounter some switch control functions, such as whether to subscribe or whether to turn on 4G. At this time we need to set up a switch page. Today we are going to introduce how the small program can dynamically control the opening and closing of the switch

Example of how a small program can dynamically control the opening and closing of a switch

Part of the code
Home page code As follows:

<view class="copyright">
    <view class="copyright_item">CopyRight:All Right Reserved</view>
    <view class="copyright_item">原创作者:HTML51.COM</view>
    <view class="copyright_item">微信小程序开发平台:51小程序</view>
    <view class="copyright_item"><image class="img" src="../copyright/image/logo.png"/></view>
    <view class="goto_counter"><button type="default" bindtap="goto_counter">点击进去控制switch的开和闭</button></view>
</view>
Copy after login

index.wxml code is as follows:

<switch checked="{{switchChecked}}"/>
<button type="default" bindtap="openSwitch">打开开关</button>
<button type="default" bindtap="closeSwitch">关闭开关</button>
<switch checked="{{switchChecked}}"/>
<button type="default" bindtap="openSwitch">打开开关</button>
<button type="default" bindtap="closeSwitch">关闭开关</button>
Copy after login

For more examples of how small programs can dynamically control the opening and closing of switch switches, please pay attention to the PHP Chinese website for related articles!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template