<template slot-scope="{ row, $index }">
<el-input
class="input-new-tag"
v-if="row.inputVisible"
v-model="row.inputValue"
ref="saveTagInput"
size="small"
@keyup.enter.native="handleInputConfirm(row)"
@blur="handleInputConfirm(row)"
>
</template>
我发现,在input按下回车键时,会调用两次handleInputConfirm方法处理数据。因为按下回车的时候调用一次方法,同时input也失去了焦点就会再调用一次方法。但是调用两次方法就会出现问题,那么如何只调用一次方法呢,请看下面:
<template slot-scope="{ row, $index }">
<el-input
class="input-new-tag"
v-if="row.inputVisible"
v-model="row.inputValue"
ref="saveTagInput"
size="small"
@keyup.enter.native="$event.target.blur"
@blur="handleInputConfirm(row)"
>
</template>
这样不管是失去焦点,还是按下回车,都只会调用一次方法,避免出现问题