当前位置:网站首页>Wx is used in wechat applet Showtoast() for interface interaction
Wx is used in wechat applet Showtoast() for interface interaction
2022-07-07 07:38:00 【richest_ qi】
List of articles
Antecedents feed
Use... In wechat applet wx.showToast()
Display message prompt box , This API Receive an object as a parameter , This object contains the following properties :
title
, Content of tips , mandatory .icon
, The icon displayed , Not required , There are four optional values , The default value issuccess
.success
, Success icon , here title Text shows at most 7 The Chinese characters .error
, Failure icon , here title Text shows at most 7 Length of Chinese characters .loading
, Load icon , here title Text shows at most 7 Length of Chinese characters .none
, Don't show icons , here title The text can display up to two lines .
image
, The local path of the custom icon ,image Has a higher priority than icon.duration
, Delay time of prompt .mask
, Whether the transparent mask is displayed ( The transparent mask can prevent touch penetration ), Boolean value , The default is false, That is, the transparent mask is not displayed .success
, Interface call successful callback .fail
, Callback for interface call failure .complete
, End of interface call ( Whether success or failure ) The callback .
Applet project
The files involved in the code are :
- app.json
- pages/index/index.wxml
- pages/index/index.wxss
- pages/index/index.js
app.json
{
"pages": [
"pages/index/index"
],
"window": {
"navigationBarBackgroundColor": "#0149af",
"navigationBarTitleText": " Login Center ",
"navigationBarTextStyle": "white"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
pages/index/index.wxml
<view class="container">
<view class="title"> Sign in </view>
<view class="list">
<view class="item">
<input type="text" data-type="username" bindinput="handleInput" placeholder=" user name " />
</view>
<view class="item">
<input type="text" password data-type="password" bindinput="handleInput" placeholder=" password " />
</view>
</view>
<button size="mini" bindtap="login"> Sign in </button>
</view>
pages/index/index.wxss
.container{
padding: 20rpx;
}
.container .title{
padding: 20rpx 0;
border-bottom: 1px solid #ddd;
font-weight: bold;
font-size: 32rpx;
}
.list{
margin: 40rpx auto 20rpx;
}
.item{
margin: 12rpx 0;
padding: 0 20rpx;
border: 1px solid #ddd;
border-radius: 6rpx;
}
.item input{
width: 100%;
height: 60rpx;
font-size: 28rpx;
}
button{
font-weight: normal;
font-size: 28rpx!important;
color: #fff;
background: #0149af;
}
pages/index/index.js
Page({
data:{
username:"",
password:""
},
handleInput(e){
const type = e.target.dataset.type;
this.setData({
[type]:e.detail.value
})
},
login(){
const {
username,password} = this.data;
if(!username){
wx.showToast({
title: ' Please enter your user name ',
icon:'error'
})
return;
}
if(!password){
wx.showToast({
title: ' Please enter your password ',
icon:'error'
})
return;
}
wx.showToast({
title: ' Login successful '
})
}
})
Related links
边栏推荐
- MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
- Deep learning Flower Book + machine learning watermelon book electronic version I found
- 外包干了三年,废了...
- Outlier detection technology of time series data
- URP - shaders and materials - light shader lit
- 微博发布案例
- 考研失败,卷不进大厂,感觉没戏了
- English translation is too difficult? I wrote two translation scripts with crawler in a rage
- 测试周期被压缩?教你9个方法去应对
- Robot technology innovation and practice old version outline
猜你喜欢
Summary of customer value model (RFM) technology for data analysis
URP - shaders and materials - light shader lit
【leetcode】1020. Number of enclaves
Make a bat file for cleaning system garbage
ASEMI整流桥RS210参数,RS210规格,RS210封装
抽丝剥茧C语言(高阶)数据的储存+练习
Deep learning Flower Book + machine learning watermelon book electronic version I found
L'externalisation a duré trois ans.
IO流 file
我理想的软件测试人员发展状态
随机推荐
Invalid table alias or column reference`xxx`
Advanced practice of C language (high level) pointer
Advanced level of C language (high level) pointer
Blue Bridge Cup Birthday candles (violence)
At the age of 20, I got the ByteDance offer on four sides, and I still can't believe it
1、 Go knowledge check and remedy + practical course notes youth training camp notes
4、 High performance go language release optimization and landing practice youth training camp notes
【leetcode】1020. Number of enclaves
Implementing data dictionary with JSP custom tag
聊聊异步编程的 7 种实现方式
面试结束后,被面试官在朋友圈吐槽了......
Make a bat file for cleaning system garbage
242. Bipartite graph determination
科技云报道:从Robot到Cobot,人机共融正在开创一个时代
KBU1510-ASEMI电源专用15A整流桥KBU1510
外包干了四年,废了...
Calculus key and difficult points record part integral + trigonometric function integral
Example of Pushlet using handle of Pushlet
三、高质量编程与性能调优实战 青训营笔记
ROS2规划系统plansys2简单的例子