Vue 提示框组件
OK,首先看看效果:

一、子组件(alert.vue)
<template>
<transition name="alert">
<div class="alert-all">
<div class="alert-wraper determine">
<p class="close-alert">
<!-- <i class="fa fa-times" aria-hidden="true" title="关闭" @click="close()"></i> -->
</p>
<p :class="[{fail: ifFail}, 'title']">{{title}}</p>
<div class="btn_wrapper">
<!--<div class="cancel" @click="ok(false)">取消</div>-->
<div class="ok" @click="ok(true)">确定</div>
</div>
</div>
</div>
</transition>
</template>
<script>
export default {
name: 'alert',
props: {
title: {
type: String,
default () {
return {}
}
},
type: {
type: String,
default () {
return {}
}
},
autoHide: {
type: Boolean,
default () {
return true
}
}
},
data () {
return {
ifFail: ''
}
},
methods: {
ok: function (flag) {
let data = {
show: flag,
type: this.type
}
this.$emit('okAlert', data)
}
},
mounted () {
if (this.type === 'fail') {
this.ifFail = true
} else {
this.ifFail = false
}
}
}
</script>
<style lang="less" scoped>
.alert-all{
position:fixed;
width:%;
height:%;
top:;
left:;
z-index:;
.alert-wraper{
width:400px;
height:160px;
background:#fff;
position:absolute;
top:;
left:;
right:;
bottom:;
margin:auto;
box-shadow:0px 0px 20px #ddd;
.close-alert{
height:30px;
height:30px;
width:%;
background:#4499ee;
position:relative;
z-index:;
i{
position:absolute;
right:;
width:30px;
height:30px;
font-size: 20px;
cursor:pointer;
color:#fff;
}
i::before{
position:absolute;
left:6px;
top:4px;
}
i:hover{
background:#6db2f8;
}
}
.fail{
color:red;
}
.title{
box-sizing: border-box;
padding: 10px;
width:%;
height:130px;
line-height: 25px;
font-size:14px;
font-weight: normal;
text-align:center;
display: flex;
justify-content: center;
align-items: center;
}
}
.determine{
height: 220px;
}
.btn_wrapper{
text-align: center;
}
.cancel, .ok{
display: inline-block;
width: 80px;
height: 30px;
border-radius: 20px;
border: 1px solid #4499ee;
text-align: center;
line-height: 30px;
color: #4499ee;
margin: 20px;
}
.cancel:hover, .ok:hover{
cursor: pointer;
box-shadow: 4px #4499ee;
}
}
.alert-enter-active,.alert-leave-active{
transition: all .4s
}
.alert-enter, .alert-leave-to{
opacity: ;
transform: translateY(-60px);
}
</style>
二、父组件中引用子组件(alert.vue)
<template>
<div class="container">
<alerter
v-if="alertManager.show"
:type="alertManager.type"
:title="alertManager.title">
</alerter>
</div>
</template>
三、父组件中定义变量
export default {
data () {
return {
alertManager: {
show: false,
type: '',
title: ''
}
}
}
四、父组件中写弹出框方法
methods: {
alert (show, type, title, autoHide) {
this.alertManager = {
show: show,
type: type,
title: title
}
if (autoHide === true) {
let that = this
setTimeout(function () {
that.alertManager.show = false
}, 2000)
}
}
}
五、调用方法
that.alert(true, 'success', '提交成功', true)
Vue 提示框组件的更多相关文章
- tooltip提示框组件
Tooltip 提示框组件 可独立于其他组件通过$.fn.tooltip.defaults重写默认的defaults.当用户移动鼠标指针在某个元素上时,出现提示信息窗口来显示额外信息.提示内容可以包含 ...
- 第一百九十六节,jQuery EasyUI,Tooltip(提示框)组件
jQuery EasyUI,Tooltip(提示框)组件 学习要点: 1.加载方式 2.属性列表 3.事件列表 4.方法列表 本节课重点了解 EasyUI 中 Tooltip(提示框)组件的使用方法, ...
- 学习EXTJS6(4)基本功能-信息提示框组件
1.使用组件,主要配置表现形式有二种(是否可以说参数) 用逗号分隔的传统参数列表方式: <script type="text/javascript"> Ext.onRe ...
- 一个vue的全局提示框组件
<template> <!-- 全局提示框 --> <div v-show="visible" class="dialog-tips dia ...
- jQuery Easy UI Tooptip(提示框)组件
我们都知道DOM节点的title属性.Tooptip组件就是比較强大的title,它能够自由的设置自己的样式.位置以及有自己相关的触发事件. 演示样例: <!DOCTYPE html> & ...
- Tooltip(提示框)组件
一.加载方式 //class加载方式 <a href="http://www.ycku.com" title="这是一个提示信息!" class=&quo ...
- vue 自定义 提示框(Toast)组件
1.自定义 提示框 组件 src / components / Toast / index.js /** * 自定义 提示框( Toast )组件 */ var Toast = {}; var sho ...
- 在vue项目中添加全局提示框
1.写一个提示框组件:msg.vue (注明:这里用两个div的原因是成功和失败的提示不能用同一个div,因为他们可能紧接着出现,所以不能从始至终只有一个提示框在工作) 2.写一个调用此组建的js : ...
- vue2.0 自定义 提示框(Toast)组件
1.自定义 提示框 组件 src / components / Toast / index.js /** * 自定义 提示框( Toast )组件 */ var Toast = {}; var sho ...
随机推荐
- python编码(31-01)
以什么方式编码,就以什么方式解码! 第一种编码与解码方式: encode()编码 decode()解码 type()查看数据类型 repr()查看数据内容 s = '你好'print(type(s)) ...
- POJ - 2778 ~ HDU - 2243 AC自动机+矩阵快速幂
这两题属于AC自动机的第二种套路通过矩阵快速幂求方案数. 题意:给m个病毒字符串,问长度为n的DNA片段有多少种没有包含病毒串的. 根据AC自动机的tire图,我们可以获得一个可达矩阵. 关于这题的t ...
- Input:type属性
1.button:定义可点击的按钮(通常与 JavaScript 一起使用来启动脚本). <input id="" type="button" name= ...
- wangEditor 菜单栏随页面滚动位置改变(吸顶)问题解决
参考:https://www.kancloud.cn/wangfupeng/wangeditor2/113980 当页面向下滚动到隐藏了菜单栏时,编辑器默认会fixed菜单栏,即让菜单栏保持『吸顶』状 ...
- Leetcode143. Reorder List重排链表
给定一个单链表 L:L0→L1→-→Ln-1→Ln , 将其重新排列后变为: L0→Ln→L1→Ln-1→L2→Ln-2→- 你不能只是单纯的改变节点内部的值,而是需要实际的进行节点交换. 示例 1: ...
- Atcoder arc085
C:HSI 期望模型,不想说. #include<cstdio> using namespace std; typedef long long ll; int main() { int n ...
- C++ 标准文件的写入读出(ifstream,ofstream)
ttp://blog.csdn.net/a125930123/article/details/53542261 注: "<<", 插入器,向流输入数据 ...
- 多线程MT和多线程MD的区别
这段时间司在招实习生,而不管是远程的电话面试或者是实际现场面试中领导都喜欢问你这个问题,但是可惜的是能很好答上来的人很少.后来发现不管是应届的实习生,甚至有些实际参加工作几年的人也未必真的了解这个问题 ...
- mybatis分页插件PageHelp的使用
1.简介 PageHelper 是国内非常优秀的一款开源的 mybatis 分页插件,它支持基本主流与常用的数据库,例如 mysql.oracle.mariaDB.DB2.SQLite.Hsqld ...
- Sequelize 中文API文档-1. 快速入门、Sequelize类
1. https://itbilu.com/nodejs/npm/VkYIaRPz-.html#api-init 2. http://docs.sequelizejs.com/manual/tutor ...