Skip to content

Commit 55fa5ac

Browse files
committed
perf: optimize the code of el-table slot-scope
1 parent a8c6e11 commit 55fa5ac

File tree

7 files changed

+46
-46
lines changed

7 files changed

+46
-46
lines changed

src/components/ErrorLog/index.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@
99
<el-dialog :visible.sync="dialogTableVisible" title="Error Log" width="80%">
1010
<el-table :data="errorLogs" border>
1111
<el-table-column label="Message">
12-
<template slot-scope="scope">
12+
<template slot-scope="{row}">
1313
<div>
1414
<span class="message-title">Msg:</span>
1515
<el-tag type="danger">
16-
{{ scope.row.err.message }}
16+
{{ row.err.message }}
1717
</el-tag>
1818
</div>
1919
<br>
2020
<div>
2121
<span class="message-title" style="padding-right: 10px;">Info: </span>
2222
<el-tag type="warning">
23-
{{ scope.row.vm.$vnode.tag }} error in {{ scope.row.info }}
23+
{{ row.vm.$vnode.tag }} error in {{ row.info }}
2424
</el-tag>
2525
</div>
2626
<br>
2727
<div>
2828
<span class="message-title" style="padding-right: 16px;">Url: </span>
2929
<el-tag type="success">
30-
{{ scope.row.url }}
30+
{{ row.url }}
3131
</el-tag>
3232
</div>
3333
</template>

src/views/dashboard/admin/components/TransactionTable.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
</template>
1212
</el-table-column>
1313
<el-table-column label="Status" width="100" align="center">
14-
<template slot-scope="scope">
15-
<el-tag :type="scope.row.status | statusFilter">
16-
{{ scope.row.status }}
14+
<template slot-scope="{row}">
15+
<el-tag :type="row.status | statusFilter">
16+
{{ row.status }}
1717
</el-tag>
1818
</template>
1919
</el-table-column>

src/views/example/list.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@
2626
</el-table-column>
2727

2828
<el-table-column class-name="status-col" label="Status" width="110">
29-
<template slot-scope="scope">
30-
<el-tag :type="scope.row.status | statusFilter">
31-
{{ scope.row.status }}
29+
<template slot-scope="{row}">
30+
<el-tag :type="row.status | statusFilter">
31+
{{ row.status }}
3232
</el-tag>
3333
</template>
3434
</el-table-column>
3535

3636
<el-table-column min-width="300px" label="Title">
37-
<template slot-scope="scope">
38-
<router-link :to="'/example/edit/'+scope.row.id" class="link-type">
39-
<span>{{ scope.row.title }}</span>
37+
<template slot-scope="{row}">
38+
<router-link :to="'/example/edit/'+row.id" class="link-type">
39+
<span>{{ row.title }}</span>
4040
</router-link>
4141
</template>
4242
</el-table-column>

src/views/tab/components/tabPane.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
</el-table-column>
2020

2121
<el-table-column min-width="300px" label="Title">
22-
<template slot-scope="scope">
23-
<span>{{ scope.row.title }}</span>
24-
<el-tag>{{ scope.row.type }}</el-tag>
22+
<template slot-scope="{row}">
23+
<span>{{ row.title }}</span>
24+
<el-tag>{{ row.type }}</el-tag>
2525
</template>
2626
</el-table-column>
2727

@@ -44,9 +44,9 @@
4444
</el-table-column>
4545

4646
<el-table-column class-name="status-col" label="Status" width="110">
47-
<template slot-scope="scope">
48-
<el-tag :type="scope.row.status | statusFilter">
49-
{{ scope.row.status }}
47+
<template slot-scope="{row}">
48+
<el-tag :type="row.status | statusFilter">
49+
{{ row.status }}
5050
</el-tag>
5151
</template>
5252
</el-table-column>

src/views/table/complexTable.vue

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@
4646
</template>
4747
</el-table-column>
4848
<el-table-column :label="$t('table.title')" min-width="150px">
49-
<template slot-scope="scope">
50-
<span class="link-type" @click="handleUpdate(scope.row)">{{ scope.row.title }}</span>
51-
<el-tag>{{ scope.row.type | typeFilter }}</el-tag>
49+
<template slot-scope="{row}">
50+
<span class="link-type" @click="handleUpdate(row)">{{ row.title }}</span>
51+
<el-tag>{{ row.type | typeFilter }}</el-tag>
5252
</template>
5353
</el-table-column>
5454
<el-table-column :label="$t('table.author')" width="110px" align="center">
@@ -67,30 +67,30 @@
6767
</template>
6868
</el-table-column>
6969
<el-table-column :label="$t('table.readings')" align="center" width="95">
70-
<template slot-scope="scope">
71-
<span v-if="scope.row.pageviews" class="link-type" @click="handleFetchPv(scope.row.pageviews)">{{ scope.row.pageviews }}</span>
70+
<template slot-scope="{row}">
71+
<span v-if="row.pageviews" class="link-type" @click="handleFetchPv(row.pageviews)">{{ row.pageviews }}</span>
7272
<span v-else>0</span>
7373
</template>
7474
</el-table-column>
7575
<el-table-column :label="$t('table.status')" class-name="status-col" width="100">
76-
<template slot-scope="scope">
77-
<el-tag :type="scope.row.status | statusFilter">
78-
{{ scope.row.status }}
76+
<template slot-scope="{row}">
77+
<el-tag :type="row.status | statusFilter">
78+
{{ row.status }}
7979
</el-tag>
8080
</template>
8181
</el-table-column>
8282
<el-table-column :label="$t('table.actions')" align="center" width="230" class-name="small-padding fixed-width">
83-
<template slot-scope="scope">
84-
<el-button type="primary" size="mini" @click="handleUpdate(scope.row)">
83+
<template slot-scope="{row}">
84+
<el-button type="primary" size="mini" @click="handleUpdate(row)">
8585
{{ $t('table.edit') }}
8686
</el-button>
87-
<el-button v-if="scope.row.status!='published'" size="mini" type="success" @click="handleModifyStatus(scope.row,'published')">
87+
<el-button v-if="row.status!='published'" size="mini" type="success" @click="handleModifyStatus(row,'published')">
8888
{{ $t('table.publish') }}
8989
</el-button>
90-
<el-button v-if="scope.row.status!='draft'" size="mini" @click="handleModifyStatus(scope.row,'draft')">
90+
<el-button v-if="row.status!='draft'" size="mini" @click="handleModifyStatus(row,'draft')">
9191
{{ $t('table.draft') }}
9292
</el-button>
93-
<el-button v-if="scope.row.status!='deleted'" size="mini" type="danger" @click="handleModifyStatus(scope.row,'deleted')">
93+
<el-button v-if="row.status!='deleted'" size="mini" type="danger" @click="handleModifyStatus(row,'deleted')">
9494
{{ $t('table.delete') }}
9595
</el-button>
9696
</template>

src/views/table/dragTable.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
</el-table-column>
4040

4141
<el-table-column class-name="status-col" label="Status" width="110">
42-
<template slot-scope="scope">
43-
<el-tag :type="scope.row.status | statusFilter">
44-
{{ scope.row.status }}
42+
<template slot-scope="{row}">
43+
<el-tag :type="row.status | statusFilter">
44+
{{ row.status }}
4545
</el-tag>
4646
</template>
4747
</el-table-column>

src/views/table/inlineEditTable.vue

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,31 +26,31 @@
2626
</el-table-column>
2727

2828
<el-table-column class-name="status-col" label="Status" width="110">
29-
<template slot-scope="scope">
30-
<el-tag :type="scope.row.status | statusFilter">
31-
{{ scope.row.status }}
29+
<template slot-scope="{row}">
30+
<el-tag :type="row.status | statusFilter">
31+
{{ row.status }}
3232
</el-tag>
3333
</template>
3434
</el-table-column>
3535

3636
<el-table-column min-width="300px" label="Title">
37-
<template slot-scope="scope">
38-
<template v-if="scope.row.edit">
39-
<el-input v-model="scope.row.title" class="edit-input" size="small" />
40-
<el-button class="cancel-btn" size="small" icon="el-icon-refresh" type="warning" @click="cancelEdit(scope.row)">
37+
<template slot-scope="{row}">
38+
<template v-if="row.edit">
39+
<el-input v-model="row.title" class="edit-input" size="small" />
40+
<el-button class="cancel-btn" size="small" icon="el-icon-refresh" type="warning" @click="cancelEdit(row)">
4141
cancel
4242
</el-button>
4343
</template>
44-
<span v-else>{{ scope.row.title }}</span>
44+
<span v-else>{{ row.title }}</span>
4545
</template>
4646
</el-table-column>
4747

4848
<el-table-column align="center" label="Actions" width="120">
49-
<template slot-scope="scope">
50-
<el-button v-if="scope.row.edit" type="success" size="small" icon="el-icon-circle-check-outline" @click="confirmEdit(scope.row)">
49+
<template slot-scope="{row}">
50+
<el-button v-if="row.edit" type="success" size="small" icon="el-icon-circle-check-outline" @click="confirmEdit(row)">
5151
Ok
5252
</el-button>
53-
<el-button v-else type="primary" size="small" icon="el-icon-edit" @click="scope.row.edit=!scope.row.edit">
53+
<el-button v-else type="primary" size="small" icon="el-icon-edit" @click="row.edit=!row.edit">
5454
Edit
5555
</el-button>
5656
</template>

0 commit comments

Comments
 (0)