import Vue from "vue";
import ErrorMessageModal from "./ErrorMessageModal.vue";

const Constructor = Vue.extend(ErrorMessageModal);

function ErrorMessageToast(vueOptions = {}, { error, businessName } = {}) {
  // 实例化子组件，然后获取到DOM结构并挂载到body上
  const instance = new Constructor({
    ...vueOptions,
  });
  instance.vm = instance.$mount();

  document.body.appendChild(instance.vm.$el);
  instance.vm.error = error;
  instance.vm.businessName = businessName;
  instance.vm.visible = true;
}

export default ErrorMessageToast;
