element UI表格可编辑

2020-11-05  本文已影响0人  Hasan_hs

效果

image.png

代码

<template>
    <div class="dismantling">
        <el-table
        :data="tableData"
        style="width: 100%">
            <el-table-column
            prop="name"
            label="姓名"
            width="180">
            </el-table-column>
            <el-table-column prop="remark" label="备注">
                <template slot-scope="{row, $index}">
                    <div><!-- @click.stop="{{changeNum($index,'editRemarkInput')}}"-->
                    <el-input
                        v-if="editable[$index]"
                        v-model="row.value"
                        size="mini"
                        class="editRemarkInput"
                        @blur="changeValue"
                    ></el-input>
                    <span v-else>{{row.remark}}</span>
                    </div>
                </template>
            </el-table-column>
        
        </el-table>
    </div>
</template>
<script>
export default {
    data(){
        return {
            tableData: [{
                name: '王小虎',
                value: '1000'
            }, {
                name: '王小虎',
                value: '1000'
            }, {
                name: '王小虎',
                value: '1000'
            }, {
                name: '王小虎',
                value: '1000'
            }],
            editable:[true,true,true,true],
        }
    },
    created() {
        let timer = getMonth(new Date());
        this.times = timer;
    },
    methods: {
        changeValue(){
            console.log(this.tableData)
        }
}
</script>
<style scoped lang="scss">
    
</style>
上一篇下一篇

猜你喜欢

热点阅读