日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

html表格点击为编辑框,el-table表格内双击或单击单元格编辑输入框、日期等

發布時間:2024/9/30 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html表格点击为编辑框,el-table表格内双击或单击单元格编辑输入框、日期等 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

需求

在el-table中想要直接點擊單元格直接由文字顯示變為編輯框狀態,而非一整行編輯或者通過展示模態框編輯,這樣目標性會比較清楚且頁面較簡潔。下面直接上代碼!

實現效果

html代碼

@blur='blurInput(scope.row.id,"name",scope.row.name)' v-focus>

{{scope.row.name}}

type="date" :clearable="false" value-format="yyyy-MM-dd" placeholder="請選擇開始日期"

@blur='blurInput(scope.row.id,"planStartTime",scope.row.planStartTime)' v-focus>

{{scope.row.planStartTime}}

js代碼

export default {

data() {

return {

//表格數據

tableList: [

{

id: 0,

name: "規劃許可階段",

planStartTime: "2021-03-09"

},

{

id: 1,

name: "施工許可階段",

planStartTime: "2021-03-09"

}

],

showInput: "",

oldData: {}

}

},

directives: {

// 通過自定義指令實現的表單自動獲得光標的操作

focus: {

inserted: function(el) {

if (el.tagName.toLocaleLowerCase() == "input") {

el.focus()

} else {

if (el.getElementsByTagName("input")) {

el.getElementsByTagName("input")[0].focus()

}

}

el.focus()

}

},

focusTextarea: {

inserted: function(el) {

if (el.tagName.toLocaleLowerCase() == "textarea") {

el.focus()

} else {

if (el.getElementsByTagName("textarea")) {

el.getElementsByTagName("textarea")[0].focus()

}

}

el.focus()

}

}

},

// 方法

methods: {

// 當input失去光標后進行的操作

async blurInput(id, name, value) {

let obj = {}

// 判斷數據是否有所改變,如果數據有改變則調用修改接口

if (this.oldData[name] != value) {

obj[name] = value //被改變的數據

// 然后再寫調用接口,提交內容的東西就可以了

console.log("===值改變了")

}

this.showInput = ""

},

/*

方法參數皆為框架方法的默認傳參

row 行數據

column 被點擊的觸發了方法的單元格

event 事件

*/

tableDbEdit(row, column, event) {

this.showInput = column.property + row.id

this.oldData[column.property] = row[column.property]

}

}

}

總結

以上是生活随笔為你收集整理的html表格点击为编辑框,el-table表格内双击或单击单元格编辑输入框、日期等的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。