@58fe/p5
Version:
pc端vue组件
35 lines (31 loc) • 600 B
JavaScript
import Vue from 'vue';
import Toast from './../../components/toast';
const plugin = {
install(vue, props = {}) {
const ToastPlugin = Vue.extend(Toast);
let $vm = new ToastPlugin({
el: document.createElement('div')
});
document.body.appendChild($vm.$el);
function toast(options = {}) {
if ($vm.show) {
return;
}
$vm = Object.assign($vm, props, options);
$vm.show = true;
}
if (!vue.$p5) {
vue.$p5 = {
toast
};
} else {
vue.$p5.toast = toast;
}
vue.mixin({
created: function() {
this.$p5 = vue.$p5;
}
});
}
};
export default plugin;