Weex例子——Toast
来源:互联网 发布:数据挖掘工程师就业 编辑:程序博客网 时间:2024/05/21 01:50
不想写废话,直接上效果。
链接:
查看效果
效果:
代码:
toast.we文件
<template> <div class="toast-wrapper"> <div id="toast" class="toast"> <text class="toast-text">{{toastText}}</text> </div> </div></template><style> .toast-wrapper{ /*固定弹出位置*/ position: fixed; /*最大宽度*/ width: 550px; /*整体居中*/ margin-left: 100px; /*距离底部位置*/ bottom: 120px; /*内容居中*/ justify-content: center; align-items: center; } .toast{ /*Toast圆角和背景*/ border-radius: 10px; background-color: #444444; /*文字居中*/ justify-content: center; align-items: center; /*默认为0,用于弹出的效果*/ opacity: 0; } .toast-text{ /*字体大小和颜色*/ font-size: 28px; color: #ffffff; /*文字padding*/ padding-top: 15px; padding-bottom: 15px; padding-left: 25px; padding-right: 25px; }</style><script> module.exports = { data:{ toastText:'' }, created:function () { var self = this; /*绑定toast事件*/ this.$on('toast', function (e) { /*显示toast*/ self.toast(e.detail); }.bind(this)); }, methods: { toast: function (text) { this.toastText = text; var self = this; var animation = require('@weex-module/animation'); /*给 id="toast" 的元素 添加显示动画*/ animation.transition(self.$el('toast'), { styles: {opacity: 1,}, duration: 400, }, function () { /*显示动画完成后设置定时器*/ setTimeout(function () { /*1000ms后对 id="toast" 的元素进行隐藏动画*/ animation.transition(self.$el('toast'), { styles: {opacity: 0,}, duration: 800, }, function () { }); },1000); }); }, } }</script>
test-toast.we
<template> <div> <div class="click" onclick="test()"> <text style="font-size: 60px; color: #ffffff">Toast</text> </div> <toast id="toast"></toast> </div></template><style> .click{ height: 100px; width: 200px; margin-left: 275px; background-color: #00bfff; justify-content: center; align-items: center; }</style><script> module.exports = { methods: { test: function (e) { this.$vm('toast').$emit('toast','我是Toast.\n--ALISURE'); } } }</script>
0 0
- Weex例子——Toast
- Weex例子——登录页面
- Android例子—自定义Toast(吐司)样式
- Weex开发调试神器——Weex Devtools
- Android Toast进阶——自定义Toast
- 微信小程序例子——使用toast消息对话框提示用户忘记输入用户名或密码
- 一个Toast例子
- 记录toast使用例子
- weex入门学习总结——新建一个weex项目和安装sublime text3及其插件
- Android——Toast
- Toast——Utils
- ReactNative——Toast
- Android—Toast
- android Toast详解以及自定义Toast例子
- Weex
- weex
- WEEX
- weex
- 织梦会员发表心情时会产生乱码
- 构造代码块--Java基础040
- Android Log(二) 将Log信息写到sd卡中并带时间
- HTML5-SVG练习
- ngxin请求行与请求头处理
- Weex例子——Toast
- 算法竞赛入门经典 习题1-3 连续和(sum)
- S1考试错题本及解析
- 分栏控制器UITabBarController管理多个视图控制器以及界面跳转
- win32 遍历 文件夹中文件
- 【NOIP2014八校联考第2场第2试9.28】帮助Bsny(help)
- CF 484E Sign on Fence
- 记一次抗DDOS演练
- 算法竞赛入门经典 习题1-4 正弦和余弦 (sincos)