index.js 619 B

12345678910111213141516171819202122232425262728
  1. import Vue from 'vue';
  2. const Indicator = Vue.extend(require('./src/indicator.vue'));
  3. let instance;
  4. export default {
  5. open(options = {}) {
  6. if (!instance) {
  7. instance = new Indicator({
  8. el: document.createElement('div')
  9. });
  10. }
  11. if (instance.visible) return;
  12. instance.text = typeof options === 'string' ? options : options.text || '';
  13. instance.spinnerType = options.spinnerType || 'snake';
  14. document.body.appendChild(instance.$el);
  15. Vue.nextTick(() => {
  16. instance.visible = true;
  17. });
  18. },
  19. close() {
  20. if (instance) {
  21. instance.visible = false;
  22. }
  23. }
  24. };