vue3 在h函数中通过ref获取组件
h函数中使用ref
·
使用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);
},
});
};
更多推荐
已为社区贡献2条内容
所有评论(0)