当前位置:网站首页>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
边栏推荐
- Detailed explanation of neo4j installation process
- BGP experiment (1)
- Sqlmap tutorial (IV) practical skills three: bypass the firewall
- 抽絲剝繭C語言(高階)數據的儲存+練習
- After 95, the CV engineer posted the payroll and made up this. It's really fragrant
- Tongda injection 0day
- The metauniverse of the platofarm farm continues to expand, with Dao governance as the core
- ../ And/
- Software acceptance test
- 外包幹了三年,廢了...
猜你喜欢
Outsourcing for four years, abandoned
At the age of 20, I got the ByteDance offer on four sides, and I still can't believe it
MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
L'étape avancée du pointeur de langage C (haut de gamme) pour l'enroulement des cocons
Simple example of ros2 planning system plansys2
【Liunx】进程控制和父子进程
mips uclibc 交叉编译ffmpeg,支持 G711A 编解码
About some details of final, I have something to say - learn about final CSDN creation clock out from the memory model
nacos
UWB learning 1
随机推荐
Make a bat file for cleaning system garbage
URP - shaders and materials - light shader lit
"Xiaodeng in operation and maintenance" meets the compliance requirements of gdpr
gatk4中的interval是什么??
How to reduce inventory with high concurrency on the Internet
After 95, the CV engineer posted the payroll and made up this. It's really fragrant
resource 创建包方式
gslx680触摸屏驱动源码码分析(gslX680.c)
vus. Precautions for SSR requesting data in asyndata function
[ANSYS] learning experience of APDL finite element analysis
测试周期被压缩?教你9个方法去应对
[semantic segmentation] - multi-scale attention
Outsourcing for four years, abandoned
考研失败,卷不进大厂,感觉没戏了
JS decorator @decorator learning notes
Talk about seven ways to realize asynchronous programming
在线直播系统源码,使用ValueAnimator实现view放大缩小动画效果
【性能压测】如何做好性能压测?
MIPS uclibc cross compile ffmpeg, support g711a encoding and decoding
../ And/