index.js 546 B

12345678910111213141516171819202122232425262728
  1. import Emitter from '../utility/emitter';
  2. import storage from './storage';
  3. import store from './store';
  4. import helper from './helpers';
  5. let bus = null;
  6. function install(Vue) {
  7. if (bus instanceof Emitter) {
  8. return;
  9. }
  10. bus = new Emitter();
  11. Object.defineProperties(Vue.prototype, {
  12. $bus: {get: () => bus},
  13. $storage: {get: () => storage},
  14. });
  15. // 爲什麽不能使用 Object.defineProperty 只定義 getter ???
  16. Vue.prototype.$store = store;
  17. helper(Vue);
  18. }
  19. export default {
  20. install,
  21. }