index.mjs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import Vue from 'vue'
  2. var isVue2 = true
  3. var isVue3 = false
  4. var Vue2 = Vue
  5. var warn = Vue.util.warn
  6. function install() {}
  7. // createApp polyfill
  8. export function createApp(rootComponent, rootProps) {
  9. var vm
  10. var provide = {}
  11. var app = {
  12. config: Vue.config,
  13. use: Vue.use.bind(Vue),
  14. mixin: Vue.mixin.bind(Vue),
  15. component: Vue.component.bind(Vue),
  16. provide: function (key, value) {
  17. provide[key] = value
  18. return this
  19. },
  20. directive: function (name, dir) {
  21. if (dir) {
  22. Vue.directive(name, dir)
  23. return app
  24. } else {
  25. return Vue.directive(name)
  26. }
  27. },
  28. mount: function (el, hydrating) {
  29. if (!vm) {
  30. vm = new Vue(Object.assign({ propsData: rootProps }, rootComponent, { provide: Object.assign(provide, rootComponent.provide) }))
  31. vm.$mount(el, hydrating)
  32. return vm
  33. } else {
  34. return vm
  35. }
  36. },
  37. unmount: function () {
  38. if (vm) {
  39. vm.$destroy()
  40. vm = undefined
  41. }
  42. },
  43. }
  44. return app
  45. }
  46. export { Vue, Vue2, isVue2, isVue3, install, warn }
  47. export * from 'vue'