修改数据,如何将原数据带到输入框
生活随笔
收集整理的這篇文章主要介紹了
修改数据,如何将原数据带到输入框
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
需求:
- 對數據進行修改時,將原本的數據顯示到輸入框中
代碼展示
<template><div><el-table:data="tableData"borderstripeheight="250"style="width:100%"><el-table-columntype="selection"width="50"></el-table-column><el-table-columnprop="id"label="ID"align='center'width="70"> <template slot-scope="scope"><span style="margin-left: 10px">{{ scope.row.id }}</span> //數據的ID</template></el-table-column><el-table-columnprop="DWMC"label="單位名稱"align='center'width="130"></el-table-column><el-table-columnprop="name" label="操作"fixed="right"align="center"width="300"><template slot-scope="scope"><el-button size='mini' type="primary" @click="changeuser(scope.$index,scope.row,scope.row.id)">修改</el-button> <el-button size='mini' type="danger" @click="deluser(scope.row.id)">刪除</el-button> </template></el-table-column> </el-table></div> </template> <script>export default{data(){return {// 綁定數據form: {DWMC:'', },}},methods:{changeuser(index,row,id){ this.form.DWMC = row.DWMC // 將輸入框中的綁定數據替換成表格展示的數據,就完成了需求 }}} </script>代碼講解
效果
- 這樣就完成需求了
總結
以上是生活随笔為你收集整理的修改数据,如何将原数据带到输入框的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Django Models 多条件查询
- 下一篇: ElementUI dialog弹框 退