vue弹窗消息组件的使用方法

时间:2021-05-26

本文实例为大家分享了vue弹窗消息组件的具体代码,供大家参考,具体内容如下

本来打算写一个那种提示完了自动消失的弹窗的,但是没有想好淡入淡出的效果。所以暂时算是半成品。

练习代码如下:

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>ys-alert-component</title> <style> input { border-radius: 5px; border: 1px solid #2f9df9; background-color: #39befb; background: -webkit-gradient(linear, 0 0, 0 100%, from(#39befb), to(#2091fc)); background: -moz-gradient(linear, 0 0, 0 100%, from(#39befb), to(#2091fc)); background: -o-gradient(linear, 0 0, 0 100%, from(#39befb), to(#2091fc)); background: -ms-gradient(linear, 0 0, 0 100%, from(#39befb), to(#2091fc)); color: #FFFFFF; height: 28px; padding: 0 20px; cursor: pointer; line-height: 28px; display: inline-block; margin-right: 5px; outline: none; } .ys-alert { display: inline-block; height: 26px; padding: 8px 25px; min-width: 200px; border-radius: 5px; box-shadow: 0 4px 12px rgba(0,0,0,.5); background: #b8d2f3; margin: 50px; } .icon { float: left; width: 26px; height: 26px; border: 3px solid #fff; border-radius: 50%; font-size: 16px; line-height: 20px; font-weight: bold; text-align: center; color: #fff; box-sizing: border-box; margin-right: 8px; } .content { float: left; line-height: 26px; font-size: 15px; color: #fff; } .success { background: #9bdda7; } .error { background: #f7d13b; } .warning { background: #e98c97; } </style> <script src="https://unpkg.com/vue/dist/vue.js"></script></head><body> <div id="app"> <input type="button" value="呼唤默认的按钮" @click="alertShow('info')"> <input type="button" value="呼唤成功的按钮" @click="alertShow('success')"> <input type="button" value="呼唤失败的按钮" @click="alertShow('error')"> <input type="button" value="呼唤警告的按钮" @click="alertShow('warning')"> <input type="button" value="呼唤美美哒博客" @click="alertShow('yuki')"> <ys-alert-component icon-bar="O" type="info" v-if="info" alert-content="我是默认的按钮哟"> </ys-alert-component> <ys-alert-component icon-bar="V" type="success" v-if="success" alert-content="我是成功的按钮哟"> </ys-alert-component> <ys-alert-component icon-bar="X" type="error" v-if="error" alert-content="我是失败的按钮哟"> </ys-alert-component> <ys-alert-component icon-bar="!" type="waring" v-if="warning" alert-content="我是警告的按钮哟"> </ys-alert-component> <ys-alert-component icon-bar="E" type="" v-if="yuki" alert-content="我是灰色定制的按钮哟" style="background-color: #ccc; color: #fff;"> <div slot="alert-content"> <span>章鱼不丸子</span> <a href="http://ponent", { props: { iconBar: { type: String, default: "" }, alertContent: { type: String, default: "请定制提醒内容" }, hideIcon: { type: Boolean, default: false }, type: { type: String, default: "" } }, template:` <div class="ys-alert" :class="type"> <slot name="alert-content"> <div class="icon" >{{ iconBar }}</div> <div class="content"> {{ alertContent }} </div> </slot> </div>` }) var vm = new Vue({ el: "#app", data: { info: false, error: false, success: false, warning: false, yuki: false }, methods: { alertShow (type) { switch (type) { case "info" : this.info = !this.info; //setTimeout("vm.info = !vm.info", 2000); break; case "error" : this.error = !this.error; //setTimeout("vm.error = !vm.error", 2000); break; case "success" : this.success = !this.success; //setTimeout("vm.success = !vm.success", 2000); break; case "warning" : this.warning = !this.warning; //setTimeout("vm.warning = !vm.warning", 2000); break; default: this.yuki = !this.yuki; //setTimeout("vm.yuki = !vm.yuki", 2000); } } } }) </script></body></html>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章