Skip to content

Commit 8edf58d

Browse files
author
luchunyu
committed
fix(table): fix table column template without rowIndex and fix datasource watch bug
1 parent 82408f8 commit 8edf58d

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/components/table/base-table.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ table
5151
slot(
5252
:name="columnsItem.key + '-base-td'"
5353
:item="dataItem"
54+
:rowIndex="index"
5455
)
5556
span.c-table__expand(v-if="columnsItem.type === 'expand'")
5657
c-icon(name="chevron-down" v-if="dataItem._showExpand")

src/components/table/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export default {
193193
>
194194
<template slot="opt-td" slot-scope="props">
195195
<div class="c-table__opt">
196-
<a href="javascript:;" @click="showIp(props.item.ip)"> 查看ip
196+
<a href="javascript:;" @click="showIp(props)"> 查看ip
197197
</a>
198198
</div>
199199
</template>
@@ -246,8 +246,9 @@ export default {
246246
}
247247
},
248248
methods: {
249-
showIp (ip) {
250-
alert('ip 为 ' + ip)
249+
showIp (props) {
250+
console.log(props)
251+
alert('ip 为 ' + props.item.ip + '行号:' + props.rowIndex)
251252
},
252253
sorter (sortObj) {
253254
this.sortKey = sortObj.key

src/components/table/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ mixin templateCell(columns)
66
slot-scope="props"
77
v-if="$scopedSlots[item.key+'-th']"
88
)
9-
slot(:name="item.key + '-th'" :item="props")
9+
slot(:name="item.key + '-th'" :item="props.item")
1010
template(
1111
v-for='item in ' + columns
1212
:slot="item.key + '-base-td'"
1313
slot-scope="props"
1414
v-if="$scopedSlots[item.key+'-td']"
1515
)
16-
slot(:name="item.key + '-td'" :item="props.item")
16+
slot(:name="item.key + '-td'" :item="props.item" :rowIndex="props.rowIndex")
1717
template(slot="expandRow" slot-scope="props")
1818
slot(name="expand" :row="props.row")
1919
mixin Table(columns, onlyhead, onlybody)
@@ -179,7 +179,7 @@ export default {
179179
watch: {
180180
datasource: {
181181
handler (newVal, oldVal) {
182-
if (newVal === oldVal) return
182+
if (newVal === this.dataList) return
183183
this.composeData()
184184
this.getColumnsDetail()
185185
this.$nextTick(_ => {

0 commit comments

Comments
 (0)