微信小程序 自定义Toast
来源:互联网 发布:阿里云服务器请求超时 编辑:程序博客网 时间:2024/06/16 11:25
Toast样式可以根据需求自定义,本例中是圆形
<!--按钮--> <view class="btn" bindtap="btn_toast">自定义Toast</view> <!--以下为toast显示的内容 opacity为透明度--> <view class="toast_box" style="opacity:{{0.9}}" wx:if="{{isShowToast}}"> {{toastText}} </view> <view class="toast_box" style="opacity:{{0.9}}" wx:if="{{isShowToast}}"> {{toastText1}} </view>
Page { background: #f9f9f9; } /*按钮*/ .btn { width: 20%; margin-left: 38%; margin-top: 100rpx; text-align: center; border-radius: 10rpx; border: 10px solid #f00; background: #f00; color: #fff; font-size: 22rpx;} /*toast*/ .toast_box { width: 30%; height: 221rpx; margin-top: 60rpx; margin-left: 35%; text-align: center; border-radius: 166rpx; background: #f00; color: #fff; font-size: 32rpx; line-height: 220rpx; }
Page({ /** * 页面的初始数据 */ data: { //toast默认不显示 isShowToast: false }, showToast: function () { var _this = this; // toast时间 _this.data.count = parseInt(_this.data.count) ? parseInt(_this.data.count) : 1000; // 显示toast _this.setData({ isShowToast: true, }); // 定时器关闭 setTimeout(function () { _this.setData({ isShowToast: false }); }, _this.data.count); }, /* 点击按钮 */ btn_toast: function () { console.log("点击了按钮") //设置toast时间,toast内容 this.setData({ count: 1500, toastText: '自定义', toastText1: 'Toast' }); this.showToast(); }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { },})
阅读全文
0 0
- 微信小程序自定义Toast
- 微信小程序 自定义Toast
- 微信小程序之自定义Toast
- 微信小程序之『自定义toast』
- 微信小程序之『自定义toast』
- 微信小程序之『自定义toast』
- 微信小程序自定义控件--toast(仿Android)
- 微信小程序自定义toast的简单实现
- 微信小程序之自定义toast弹窗
- 微信小程序之自定义toast实例 —— 微信小程序实战系列(6)
- 微信小程序之自定义toast实例 —— 微信小程序实战系列(6)
- 自定义Toast、程序退出时Toast也退出、Toast的用法
- 自定义Toast
- 自定义Toast
- 自定义Toast
- 自定义Toast
- 自定义toast
- 自定义toast
- 论文笔记:Evaluation of local spatio-temporal features for action recognition
- Javaweb查询数据并转发
- Java开发中常用到运算符的功能与误区
- 6.6题解总结
- QT显示图片(一)
- 微信小程序 自定义Toast
- spring的普通类中如何取session和request对像
- GitHub提交代码成功后并不显示绿格子
- 数据库日期字段类型错误
- python-中文编码
- 后缀数组——BZOJ1031 [JSOI2007]字符加密Cipher
- 合并区间
- [建筑]柱子包面和踢脚的插件用法
- tar批量压缩目录