support Message

support Message
This commit is contained in:
梁灏 2017-03-09 22:21:54 +08:00
parent a538b6751f
commit 6cadeba44f
11 changed files with 59 additions and 67 deletions

View file

@ -1,18 +1,21 @@
<template>
<div :class="classes" :style="style">
<Notice v-for="notice in notices"
<div :class="classes" :style="styles">
<Notice
v-for="notice in notices"
:key="notice"
:prefix-cls="prefixCls"
:style="notice.style"
:styles="notice.styles"
:content="notice.content"
:duration="notice.duration"
:closable="notice.closable"
:key="notice.key"
:name="notice.name"
:transition-name="notice.transitionName"
:on-close="notice.onClose">
</Notice>
</div>
</template>
<script>
// todo :key="notice"
import Notice from './notice.vue';
const prefixCls = 'ivu-notification';
@ -30,7 +33,7 @@
type: String,
default: prefixCls
},
style: {
styles: {
type: Object,
default: function () {
return {
@ -63,25 +66,25 @@
},
methods: {
add (notice) {
const key = notice.key || getUuid();
const name = notice.name || getUuid();
let _notice = Object.assign({
style: {
styles: {
right: '50%'
},
content: '',
duration: 1.5,
closable: false,
key: key
name: name
}, notice);
this.notices.push(_notice);
},
close (key) {
close (name) {
const notices = this.notices;
for (let i = 0; i < notices.length; i++) {
if (notices[i].key === key) {
if (notices[i].name === name) {
this.notices.splice(i, 1);
break;
}