Search code examples
vue.jselement-ui

Able to enable row-click in Element UI for certain condition VueJS


I just want to ask how to enable the row click event in Element UI only for a certain condition. For example, the row should only be clicked if the status is 'Approved'

<el-table @row-click="view"> <!--the row can only be clicked if the status is 'Approved' -->
</el-table>

I don't have any idea about it. Or this code can be effective: :row-clicked


Solution

  • You can do something like, @row-click="condition ? view : undefined". if condition is true it will call the function else nothing will happen.

    You can also use v-on="condition ? { 'row-click': view } : {}".