daily pastebin goal
9%
SHARE
TWEET

Untitled

a guest Jan 16th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.     import set_interceptors from "./plugins/popups.js"
  3.     export default {
  4.         name: 'AppInterface',
  5.         data: () => ({
  6.             popup: {},
  7.             popup_queue: []
  8.         }),
  9.         watch: {
  10.             popup_queue: function(val) {
  11.                 if(val.length>0) {
  12.                     this.popup = val[0]
  13.                     if (!this.popup.timeout) {
  14.                         this.popup.timeout = setTimeout(function(){
  15.                                 val.shift()
  16.                             }, 6000)
  17.                     }
  18.                 }
  19.             }
  20.         },
  21.         created() {
  22.             set_interceptors(this.popup_queue); // устанавливает перехватчик на axios, уже работает
  23.         },
  24.     }
  25. </script>
  26.    
  27. <v- .... @click="$popup_queue.push({message:'test'})" >
  28.    
  29. ....
  30. const bus = new Vue();
  31. Vue.prototype.$bus = bus;
  32. ...
  33.    
  34. this.$bus.$emit("test", this.popup_queue);
  35.  this.$bus.$on("test", this.handler);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top