So I am creating tables (element plus table) by looping.
<el-table ref="tableRef" v-for="(tab,index) in r" :data="tab" :key="index" border style="width: 100%" height="500" @selection-change="handleSelectionChange" @header-click="contextmenu">
I want to define tableRef
as a instance type of Eltable
like they do here (https://element-plus.org/en-US/component/table.html#filter)
<script lang="ts" setup>
import { ref } from 'vue'
import { ElTable } from 'element-plus'
import type { TableColumnCtx } from 'element-plus/es/components/table/src/table-column/defaults'
interface User {
date: string
name: string
address: string
tag: string
}
const tableRef = ref<InstanceType<typeof ElTable>>() <--
const resetDateFilter = () => {
tableRef.value!.clearFilter(['date'])
}
But for some reason I am getting a syntax error Unexpected Token
where the ()
after the ElTable>>
is the unexpected token.
How else can I define tableRef
as an instance of Element plus table and where should I define it as I am working in a vue project, I was thinking the best place to define tableRef
is inside the data(){return{ tableRef: ref<InstanceType<typeof ElTable>>()}}
or inside mounted()
.