vue-bus.esm.js 837 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*!
  2. * vue-bus v1.2.1
  3. * https://github.com/yangmingshan/vue-bus
  4. * @license MIT
  5. */
  6. function VueBus(Vue) {
  7. var bus = new Vue();
  8. Object.defineProperties(bus, {
  9. on: {
  10. get: function get() {
  11. return this.$on.bind(this)
  12. }
  13. },
  14. once: {
  15. get: function get() {
  16. return this.$once.bind(this)
  17. }
  18. },
  19. off: {
  20. get: function get() {
  21. return this.$off.bind(this)
  22. }
  23. },
  24. emit: {
  25. get: function get() {
  26. return this.$emit.bind(this)
  27. }
  28. }
  29. });
  30. Object.defineProperty(Vue, 'bus', {
  31. get: function get() {
  32. return bus
  33. }
  34. });
  35. Object.defineProperty(Vue.prototype, '$bus', {
  36. get: function get() {
  37. return bus
  38. }
  39. });
  40. }
  41. if (typeof window !== 'undefined' && window.Vue) {
  42. window.Vue.use(VueBus);
  43. }
  44. export default VueBus;