<template>
<el-table
:data="tableData"
style="width: 100%"
v-loading="loading"
:row-class-name="tableRowClassName"
>
<el-table-column prop="id" label="id" min-width="100"/>
<el-table-column prop="remark" label="备注" width="200" show-overflow-tooltip>
<template #default="scope">
<el-input
v-if="scope.row.edit"
v-model="scope.row.remark"
@change="remarkChangeHandler(scope.row)"
@mouseleave="scope.row.edit=false"
style="width: 185px" type="textarea" autosize
maxlength="200" show-word-limit word-limit-position="outside"
/>
<el-text v-else class="mx-1" @mouseenter="scope.row.edit=true">
{{ scope.row.remark?scope.row.remark:"(鼠标移动到此处编辑备注)" }}
</el-text>
</template>
</el-table-column>
</el-table>
</template>
<script lang="ts" setup>
import {ref} from 'vue'
import request from '@/util/request.ts';
import {ElMessage} from 'element-plus'
Interface MyData{
id: string
remark: string
edit: boolean
}
const tableData= ref([])
/**
* 更新备注
*/
const remarkChangeHandler = (row: MyData) => {
//你的处理
request.post('/remark', {
id: row.id
remark: row.remark
}).then(res => {
ElMessage({
message: row.id + '备注更新成功',
type: 'success',
})
});
}
</script>
<style>
</style>
Vue3+ElementPlus鼠标悬停编辑保存
最新推荐文章于 2026-06-23 13:52:18 发布

864

被折叠的 条评论
为什么被折叠?



