index.js 881 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import i18n from '@/util/lang/lang'
  2. let dom = null
  3. async function asyncConstructor (Vue, comp) {
  4. if (!comp) {
  5. let component = await import('./index.vue')
  6. comp = Vue.extend(component.default)
  7. return comp
  8. }
  9. return comp
  10. }
  11. let packetGet = {}
  12. packetGet.install = function (Vue, store) {
  13. let instance
  14. Vue.prototype.$packetGet = async (info, isShowDetail) => {
  15. let Constructor = await asyncConstructor(Vue, dom)
  16. if (instance) {
  17. document.body.removeChild(instance.$el)
  18. instance = null
  19. }
  20. instance = new Constructor({
  21. el: document.createElement('div'),
  22. computed: {
  23. $store () { return store }
  24. },
  25. i18n,
  26. data () {
  27. return {
  28. visible: false,
  29. info,
  30. isShowDetail
  31. }
  32. }
  33. })
  34. document.body.appendChild(instance.$el)
  35. }
  36. }
  37. export default packetGet