在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效果的更多相关文章

  1. 微信小程序 折叠效果

    <view class='help'> <view class='help_item'> <view class='title' data-index='1' catch ...

  2. 微信小程序 --- 日历效果

    wxml部分: <view class='box1' style='width: {{ sysW * 7 }}px'> <view class='dateBox'>{{ yea ...

  3. 微信小程序学习指南

    作者:初雪链接:https://www.zhihu.com/question/50907897/answer/128494332来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...

  4. weapp微信小程序初探demo

    https://github.com/donglegend/weapp-demo 参考文档开发工具安装微信weapp API git项目源码微信小程序 demo效果展示效果预览

  5. 近期热门微信小程序demo源码下载汇总

    近期微信小程序demo源码下载汇总,乃小程序学习分析必备素材!点击标题即可下载: 即速应用首发!原创!电商商场Demo 优质微信小程序推荐 -秀人美女图 图片下载.滑动翻页 微信小程序 - 新词 GE ...

  6. 微信小程序初见+nodejs服务端 (一个简单的博客)

    推荐网址: 腾讯云快速开发(nodejs前后端):https://developers.weixin.qq.com/miniprogram/dev/qcloud/qcloud.html#%E5%AF% ...

  7. 微信小程序开发学习资料

    作者:初雪链接:https://www.zhihu.com/question/50907897/answer/128494332来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...

  8. 微信小程序资源整理

    微信小程序相关的文档.教程.开源项目等资源的整理,以便于开发学习使用. —— —— 收录仅作个人学习使用,涉及侵权行为及时联系: maple_6392@163.com 项目地址:GitHub | 码云 ...

  9. 微信小程序学习 动手撸一个校园网小程序

    动手撸一个校园网微信小程序 高考完毕,想必广大学子和家长们都在忙着查询各所高校的信息,刚好上手微信小程序,当练手也当为自己的学校做点宣传,便当即撸了一个校园网微信小程序. 效果预览 源码地址:Gith ...

随机推荐

  1. IOS APP开发UI上的尺寸注意问题(屏幕、适配、分辨率)

  2. ASPX导入JS,JavaScript乱码怎么办

    不管你把JS改成UTF-8还是ASCII格式,弹出都是乱码. 你只要在ASPX文件顶部加上"ResponseEncoding="gb2312" ContentType=& ...

  3. 右键菜单 GenericMenu

    http://www.cnblogs.com/zhaoqingqing/p/3799294.html 自定义窗口中使用右键菜单: // This example shows how to create ...

  4. 错误代码: 1066 Not unique table/alias: &#39;c&#39;

    1.错误描写叙述 1 queries executed, 0 success, 1 errors, 0 warnings 查询:SELECT (SELECT CONCAT( s.name, '/', ...

  5. ubuntu16.4安装后做的事情

    1.安装搜狗拼音输入法 http://pinyin.sogou.com/linux/help.php 2.安装谷歌浏览器 http://jingyan.baidu.com/article/335530 ...

  6. CentOS 6.3系统安装配置KVM虚拟机

      作业环境 服务器端 操作系统:CentOS 6.3 final x86_64 IP: 133.133.10.50 Hostname:myKVM KVM:qemu-kvm-0.12.1.2-2.29 ...

  7. 【转帖】基于Zookeeper的服务注册与发现

    http://www.techweb.com.cn/network/hardware/2015-12-25/2246973.shtml 背景 大多数系统都是从一个单一系统开始起步的,随着公司业务的快速 ...

  8. 【LeetCode】102. Binary Tree Level Order Traversal (2 solutions)

    Binary Tree Level Order Traversal Given a binary tree, return the level order traversal of its nodes ...

  9. 执行 maven 命令 报错Unable to add module to the current project as it is not of packaging type 'pom'[转]

    今天学习在本地搭建Maven工程时,执行了mvn archetype:generate 命令,报错. Unable to create project from archetype [org.apac ...

  10. Bootstrap 的模态框类

    事件类型 描述 show.bs.modal show 方法调用之后立即触发该事件.如果是通过点击某个作为触发器的元素,则此元素可以通过事件的relatedTarget 属性进行访问. shown.bs ...