使用h函数的方式使用组件,应用场景需要使用组件原本带的方法,经过多次尝试,亲测以下方法可行:

const Cascader = (props: any, emit: any) => {
 const elCascader = ref()
 return h(ElCascader, {
  modelValue: props.modelValue,
  ...
  ref: elCascader,
  onChange: ($event: any) => {
   const checkNodes = elCascader.value.getCheckedNodes();
   props.change?.($event, checkNodes);
  },
 });
};

参考:模板引用 | Vue.js

 

 

Logo

前往低代码交流专区

更多推荐