0

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().

Tallion 22
  • 141
  • 1
  • 11
  • The problem isn't how the variable is defined. The error means that TS isn't parsed. It's unknown under which circumstances the error occurs, it's specific to your case. If you have the problem in IDE but not on build this means the problem is specific to IDE and nothing else. – Estus Flask Jul 26 '22 at 21:29
  • I have the problem on build – Tallion 22 Jul 26 '22 at 21:34

0 Answers0