ankurk91 / vue-loading-overlay

Vue.js component for full screen loading indicator :cyclone:
https://ankurk91.github.io/vue-loading-overlay/
MIT License
1.24k stars 101 forks source link

How to global config for default slot? #54

Closed rogerluo410 closed 4 years ago

rogerluo410 commented 4 years ago
Vue.use( 
    Loading,
   {
    // props
   }
  // {
  //   // slots
  //   default: this.$createElement("loading-img")
  // }
);

As we know, we can't use this.$createElement method in Vue.use(), How can we config default slot globally? thank you!

ankurk91 commented 4 years ago

You can do it like:

const custom = Vue.extend({
  template: `<h3 class="custom">loading</h3>`
});

Vue.component('custom-loader', custom);

Vue.use(VueLoading, {
  // options
} , {
  // slots
   default: (new Vue()).$createElement('custom-loader')
});

https://jsfiddle.net/L10q7daz/1/