微信小程序 - toptip效果
在Page顶部下滑一个提示条 , 代码见 /mixins/UIComponent.js ,其中的self 可以认为是微信小程序的Page对象
效果: 默认2秒展示,上移动画隐藏

/**
* 展示顶部 tip , 多次快速调用,会覆盖前次展示
*/
UIComponent.showToptip = function (opt = {}) {
var self = this;
if (self.uiComponent_topTip_timer) { //如果之前有timer,那么取消后重新创建
clearTimeout(self.uiComponent_topTip_timer);
}
if (typeof opt == "string") {
opt = {
content: opt
}
}
//默认参数,也是外部参考的传参
var defaultOptions = {
show: false, //是否显示,默认不显示
style: "", //外部传入的自定义样式,比如字体,背景色
content: "操作成功", //默认的内容
duration: 2000 //显示延迟几秒
};
let app = getApp();
opt = app.util.extend(defaultOptions, opt);
self.setData({
'uiComponent.toptip.show': true,
'uiComponent.toptip.style': opt.style,
"uiComponent.toptip.content": opt.content
});
self.uiComponent_topTip_timer = setTimeout(() => {
self.setData({
'uiComponent.toptip.show': false
});
}, opt.duration);
}
<view class="uiComponent uiComponent_toptip uiComponent_toptip_{{uiComponent.toptip.show &&'active'}}"
style="{{uiComponent.toptip.style}}"
>{{uiComponent.toptip.content}} </view>
.uiComponent {
z-index:;
}
/* toptip 顶部提示条效果 */
.uiComponent_toptip {
width: 100%;
display: block;
top:-50px;
position: fixed; text-align: center;
line-height: 2.3;
font-size: 30rpx;
transition: all .2s linear ;
}
.uiComponent_toptip_active {
top:;
transition: all .3s linear ;
min-height: 32px;
color: #fff;
background-color: rgba(0,0,0,.8);
}
微信小程序 - toptip效果的更多相关文章
- 微信小程序 折叠效果
<view class='help'> <view class='help_item'> <view class='title' data-index='1' catch ...
- 微信小程序 --- 日历效果
wxml部分: <view class='box1' style='width: {{ sysW * 7 }}px'> <view class='dateBox'>{{ yea ...
- 微信小程序学习指南
作者:初雪链接:https://www.zhihu.com/question/50907897/answer/128494332来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...
- weapp微信小程序初探demo
https://github.com/donglegend/weapp-demo 参考文档开发工具安装微信weapp API git项目源码微信小程序 demo效果展示效果预览
- 近期热门微信小程序demo源码下载汇总
近期微信小程序demo源码下载汇总,乃小程序学习分析必备素材!点击标题即可下载: 即速应用首发!原创!电商商场Demo 优质微信小程序推荐 -秀人美女图 图片下载.滑动翻页 微信小程序 - 新词 GE ...
- 微信小程序初见+nodejs服务端 (一个简单的博客)
推荐网址: 腾讯云快速开发(nodejs前后端):https://developers.weixin.qq.com/miniprogram/dev/qcloud/qcloud.html#%E5%AF% ...
- 微信小程序开发学习资料
作者:初雪链接:https://www.zhihu.com/question/50907897/answer/128494332来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...
- 微信小程序资源整理
微信小程序相关的文档.教程.开源项目等资源的整理,以便于开发学习使用. —— —— 收录仅作个人学习使用,涉及侵权行为及时联系: maple_6392@163.com 项目地址:GitHub | 码云 ...
- 微信小程序学习 动手撸一个校园网小程序
动手撸一个校园网微信小程序 高考完毕,想必广大学子和家长们都在忙着查询各所高校的信息,刚好上手微信小程序,当练手也当为自己的学校做点宣传,便当即撸了一个校园网微信小程序. 效果预览 源码地址:Gith ...
随机推荐
- (剑指Offer)面试题44:扑克牌的顺子
题目: 从扑克牌中随机抽5张牌,判断是不是一个顺子,即这五张牌是不是连续的,2~10为数字本身,A为1,J为11,Q为12,K为13,而大小王可以看成任意数字. 思路: 把5张牌看成一个数组,就看排序 ...
- 开源工作流CCBPM中关于解决谷歌等浏览器silverlight的问题
CCBPM的流程设计器和表单设计器.是通过silverlight实现的. 有些用户和学习者在安装完CCFlow,执行流程设计器时,常常会出现提示安装silverlight.明明已经安装了,为什么还会出 ...
- 为pc编译配置安装当前最新的内核
搜索公众号:itxxgh (IT学习干货),全公益.免费.定期,提供,<IT学习教程>.不会骚扰大家,仅仅需轻点关注,也会传播<中华传统文化>传播正能量. 或扫描二维码 1 ...
- Unity3D For Android 开发教程
原地址:http://game.ceeger.com/Unity/Doc/2011/Unity3D_For_Android.html 我自认为抵挡诱惑的能力还是很强大的,关键的时候还能把持住自己.今天 ...
- GameCenter 使用指南
原地址:http://www.cocoachina.com/gamedev/misc/2010/1022/2229.html GameCenter 为单机游戏为主的 iPhone 游戏平台引入了社会化 ...
- CodeForces 2A - Winner(模拟)
题目链接:http://codeforces.com/problemset/problem/2/A A. Winner time limit per test 1 second memory limi ...
- 干货首发,能够清理,带动画的自己定义控件CuteEditText
转载请注明出处:王亟亟的大牛之路 总想创造个什么,可是又不知道要详细做什么. 那么仅仅有丛一直用的那些东西上面開始创造,哈哈.然后再摸索的过程中进步吧. 先上一下效果: 这样的带删除button的形式 ...
- linux sort 、uniq 命令
以文件的每行为单位,从左往右依次按ascii码进行比较 sort sort.txt #默认为升序 -u:去除重复行 sort -u sort.txt -r:降序排列 sort -r sort.txt ...
- MVC之Ajax.BeginForm使用详解之更新列表 mvc验证jquery.unobtrusive-ajax
MVC之Ajax.BeginForm使用详解之更新列表 1.首先,请在配置文件设置如下:(该项默认都存在且为true) <add key="UnobtrusiveJavaScrip ...
- 如何修改浏览器默认的alert样式?
window.alert = function(str) { var shield = document.createElement("DIV"); shield.id = &qu ...