fezui
Version:
FEZUI 是一套基于 Vue 的支持多终端的开源UI交互组件库,致力于积木式的快速构建项目,提升产品体验和开发效率、降低开发和维护成本。
41 lines (34 loc) • 1.1 kB
JavaScript
import Notification from './notification.vue';
import Vue from 'vue';
import { camelcaseToHyphen } from '../../../utils/assist';
Notification.newInstance = properties => {
const _props = properties || {};
let props = '';
Object.keys(_props).forEach(prop => {
props += ' :' + camelcaseToHyphen(prop) + '=' + prop;
});
const div = document.createElement('div');
div.innerHTML = `<notification${props}></notification>`;
document.body.appendChild(div);
const notification = new Vue({
el: div,
data: _props,
components: { Notification }
}).$children[0];
return {
notice(noticeProps) {
notification.add(noticeProps);
},
remove(name) {
notification.close(name);
},
component: notification,
destroy() {
notification.closeAll();
setTimeout(function() {
document.body.removeChild(document.getElementsByClassName('fez-message')[0].parentElement);
}, 500);
}
};
};
export default Notification;