当前位置:网站首页>Switch usage (wechat applet)
Switch usage (wechat applet)
2022-04-23 14:04:00 【one billion twenty-nine million one hundred and seventy-nine th】
switch It can be understood as the use of switches , Is to open and close .switch Open is true, Closed yes false, You can also bind functions , Get whether the current state is on or off in the binding function , Then write code according to your own logic .
wxxml
<view class="section">
<view class="section-title"> The lamp </view>
<view class="section-form">
<view class="form-group">
<label> Light control </label>
<!--checked The default is true bindchange You can bind functions -->
<switch color="#007aff" checked bindchange="light" ></switch>
</view>
</view>
</view>
js
Corresponding to the above light function , adopt e.detail.value The current status is true still false Then write the logic code , This is the control light ( Raspberry pie )
// The lamp 26 high1 low1
light(e){
// Get the status
var status=e.detail.value
Do judgment
if(status==true){
console.log(" turn on the light ")
// Send a request to the background
wx.request({
url: 'http://localhost:8080/lg/sshlinuxController/jqcontrol',
data: {
com: "python high1.py"
}
})
}else{
console.log(" Turn off the lights ")
wx.request({
url: 'http://localhost:8080/lg/sshlinuxController/jqcontrol',
data: {
com: "python low1.py"
}
})
}
},
wxcss
I want to use the code here css And share it with you
/* pages/scan/scan.wxss */
page {
background-color: #fafafa;
}
.name {
margin-top: 20rpx;
margin-bottom: 40rpx;
line-height: 32px;
font-size: 17.25pt;
color: #000000;
}
.time-section {
margin-top: 110rpx;
}
.time {
display: flex;
flex-direction: row;
justify-content: center;
}
.hourminuts {
line-height: 154rpx;
font-size: 41.25pt;
color: rgba(0, 0, 0, 0.87);
}
.seconds {
line-height: 72rpx;
font-size: 18.75pt;
color: #f5a623;
margin: auto 0rpx 20rpx 0rpx;
}
.date {
margin-top: 12rpx;
text-align: center;
font-weight: 500;
line-height: 22px;
font-size: 12pt;
color: rgba(0, 0, 0, 0.54);
margin-bottom: 60rpx;
}
.footer {
/*display: flex;
flex-direction: column;
justify-content: center;*/
/*align-items: center;*/
margin: 0 auto;
width: 80%;
}
.to-clock {
background-color: #22a1e0;
color: #ffffff;
margin-bottom: 40rpx;
}
.hover-to-clock {
opacity: 0.7;
}
.to-list {
color: rgba(0, 0, 0, 0.54);
margin-bottom: 40rpx;
}
.hover-to-list {
opacity: 0.7;
}
.main-body {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
}
.section {
width: 100%;
padding: 20rpx;
}
.section-title {
font-size: 35rpx;
width: 300rpx;
height: 80rpx;
line-height: 80rpx;
padding-left: 20rpx;
border-bottom: 4rpx solid #000;
}
.section-form {
display: flex;
flex-direction: column;
padding: 10rpx 20rpx;
}
.form-group {
display: flex;
flex-direction: row;
width: 100%;
height: 80rpx;
line-height: 80rpx;
font-size: 32rpx;
}
.form-group label {
width: 75%;
}
.form-group input,
.form-group switch {
height: 80rpx;
width: 60rpx;
line-height: 80rpx;
text-align: center;
}
.form-group input {
border-bottom: 2rpx solid #000;
height: 60rpx;
line-height: 60rpx;
}
版权声明
本文为[one billion twenty-nine million one hundred and seventy-nine th]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231401297976.html
边栏推荐
- Choreographer full resolution
- Chrome插件 之 Selenium IDE、XPath 安装
- CDH cluster integration Phoenix based on CM management
- Pytorch 经典卷积神经网络 LeNet
- Oracle alarm log alert Chinese trace and trace files
- Check in system based on ibeacons
- 快速安装mongodb
- poi操作word模板替换数据并且导出word
- New关键字的学习和总结
- Cdh6 based on CM management 3.2 cluster integration atlas 2 one
猜你喜欢
随机推荐
PyMySQL
Yarn online dynamic resource tuning
Nifi 快速安装及文件同步操作
PATH环境变量
基础知识学习记录
STM32 learning record 0007 - new project (based on register version)
编程旅行之函数
封装logging模块
Neuron and neural network
JS brain burning interview question reward
_模_板_
websocket
AtomicIntegerArray源码分析与感悟
Programming travel function
Quartus prime hardware experimental development (de2-115 board) experiment II function adjustable comprehensive timer design
leetcode--357. Count the number of different figures
Taobao released the baby prompt "your consumer protection deposit is insufficient, and the expiration protection has been started"
log4j 输出日志信息到文件中
Atcoder beginer contest 248c dice sum (generating function)
VsCode-Go