vue 指令调用组件

1、selectRecipeDate.vue





2、gui.js

import Vue from "vue";
export default (model) => {
  return (options) => {
    let vm = new (Vue.extend({
      ...model,
      store: require("../store").default //状态
    }))
    vm.$mount();
    document.body.appendChild(vm.$el);
    vm.$on('close', () => {
      vm.$el.parentNode.removeChild(vm.$el);
      vm.$destroy();
    })
    // vm.$emit('open',options); 
    return vm;
  }
}
//提交处方选择提交时间
import gui from "@/libs/gui";
  var selectRecipeDate = gui(require("@/components/selectRecipeDate"));
  Vue.prototype.$selectRecipeDate = () => {
    return new Promise((resolve, reject) => {
      var vm = selectRecipeDate();    
      vm.open();
      vm.$on("close", e => {
        if (e == null) return reject();
        resolve(e);
      });
    });
  };

你可能感兴趣的:(vue 指令调用组件)