index.js 589 B

123456789101112131415161718192021222324252627282930
  1. import packetGet from './index.vue'
  2. packetGet.install = function (Vue, store) {
  3. const Constructor = Vue.extend(packetGet)
  4. let instance
  5. Vue.prototype.$packetGet = (info) => {
  6. if (instance) {
  7. document.body.removeChild(instance.$el)
  8. instance = null
  9. }
  10. instance = new Constructor({
  11. el: document.createElement('div'),
  12. computed: {
  13. $store () { return store }
  14. },
  15. data () {
  16. return {
  17. visible: false,
  18. info
  19. }
  20. }
  21. })
  22. document.body.appendChild(instance.$el)
  23. }
  24. }
  25. export default packetGet