JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//unpkg.com/vue/dist/vue.js"></script>
<script src="//unpkg.com/element-ui/lib/index.js"></script>
<div id="app">
<template>
<el-button plain @click="open">
打开通知
</el-button>
</template>
</div>
SCSS
@import url("//unpkg.com/element-ui/lib/theme-default/index.css");
Babel + JSX
var Main = {
data() {
return {
alreadyExists: false
}
},
methods: {
open() {
if (this.alreadyExists) return
this.$notify({
title: '提示',
message: '同一时刻只能显示一条消息',
duration: 1000,
onClose: this.handleClose(false)
})
this.alreadyExists = true
},
handleClose(a) {
this.alreadyExists = a;
}
}
}
var Ctor = Vue.extend(Main)
new Ctor().$mount('#app')