Skip to content

ref 组件实例

获取并标注类型

在 vue3 + typescript 的项目中,为了获取到组件实例并增加类型,可以使用这样的写法以 element-plus 为例:

txt
import { ElTable } from "element-plus";
const tableRef = ref<null | InstanceType<typeof ElTable>>(null);

更好的封装方案

贡献者

The avatar of contributor named as ruan-cat ruan-cat

页面历史