UNPKG

vue-toast-demo-zxy

Version:

a toast plugin for mobile

32 lines 947 B
import ToastComponet from './vue-toast.vue' var Toast = {} Toast.install = function(Vue,options){ var opt ={ minit:3000 } for(key in options){ opt[key] = options[key] } Vue.property.$toast = function(msg,options){ if(options == 'object'){ for(key in options){ opt[key] = options[key] } } const vueController = Vue.extend(ToastComponet); var instace = new vueController().$mount(document.createElement('div')); instace.msg = msg instace.visible = true setTimeout(()=>{ instace.visible = false document.body.removeChild(instace.$el); },opt.minit) } Vue.property.$toast['show']= function(msg,options){ Vue.property.$toast(msg,options) } Vue.property.$toast['success']= function(msg,options){ Vue.property.$toast(msg,options) } } export default Toast