VUE~~~table编辑列功能
16lz
2021-01-22
编辑列的功能
//列信息中配置:scopedSlots: { customRender: 'editname' }//<template slot="editname" slot-scope="text, record"> <editable-cell :col="'name'" :record="record" @change="handleEditname(record, 'name', $event)"/></template>//模板&方法const EditableCell = { props: { record: Object, col: String }, data () { return { editable: false, inputtext: "" }; }, methods: { handleChange (e) { const value = e.target.value; this.record[this.col] = value }, check () { this.editable = false; this.$emit('change', this.record[this.col]); }, edit () { this.editable = true this.inputtext = this.record[this.col] }, close () { this.editable = false this.record[this.col] = this.inputtext } }, render () { if (this.editable) { return ( <div class="editable-cell"> <div class="editable-cell-input-wrapper"> <a-input value={this.record[this.col]} {...{ on: { pressEnter: this.check, change: this.handleChange } }} /> <a-icon type="check" class="editable-cell-icon-check" {...{ on: { click: this.check } }} /> <a-icon type="close" style="margin-left:8px;" {...{ on: { click: this.close } }} /> </div> </div> ) } else { return ( <div class="editable-cell"> <div class="editable-cell-text-wrapper"> {this.record[this.col] || ''} <a-icon type="edit" class="editable-cell-icon" {...{ on: { click: this.edit } }} /> </div> </div> ) } }};//方法handleEditname (record, dataIndex, value) {}
更多相关文章
- 推荐一种Python安装的方法
- 如何找到属于自己高效学习方法?
- Pyecharts制作地图的几种方法评析
- 词云图的几种制作方法评测,你pick哪款
- 便捷搭建 Zookeeper 服务器的方法,好用,收藏~
- 自学系列 | 就谈自学方法!
- php性能优化的方法介绍
- PHP操作Redis数据库常用方法(总结)
- php中比较两个数组差异的方法