表格表頭如圖所示,有 40-45,45-50 數(shù)據(jù),且以輸入框形式呈現(xiàn),現(xiàn)想修改其數(shù)據(jù)或點擊右側(cè)加號增加新數(shù)據(jù)編輯。結(jié)果不能輸入,部分代碼如下
<template v-if="columnData.length > 0">
<el-table-column v-for="(item,index) in columnData" :prop="item.prop" :width="item.width">
<template slot="header">
<el-input size="mini" :disabled="pageType == 'view'" v-model="item.label"></el-input>
<i class="el-icon-remove-outline" @click="deleteSizeColumns(item.prop)" style="font-size: 16px;"></i>
</template>
<template slot-scope="scope">
<span v-if="scope.row[item.prop] !== null">
<el-input size="mini" :disabled="pageType == 'view'" v-model="scope.row[item.prop]"></el-input>
</span>
</template>
</el-table-column>
<el-table-column>
</template>
我看在這一塊template
中不需要用到 scope
去獲取數(shù)據(jù),于是沒有加上 slot-scope="scope"
<template slot="header">
<el-input size="mini" :disabled="pageType == 'view'" v-model="item.label"></el-input>
<i class="el-icon-remove-outline" @click="deleteSizeColumns(item.prop)" style="font-size: 16px;"></i>
</template>
結(jié)果不能輸入,解決方法就是在表頭自定義時將漏掉的slot-scope="scope"
加回去文章來源:http://www.zghlxwxcb.cn/news/detail-775190.html
<template slot="header" slot-scope="scope">
<el-input size="mini" :disabled="pageType == 'view'" v-model="item.label"></el-input>
<i class="el-icon-remove-outline" @click="deleteSizeColumns(item.prop)" style="font-size: 16px;"></i>
</template>
附:
Scoped slot 可以獲取到 row, column, $index 和 store(table 內(nèi)部的狀態(tài)管理)的數(shù)據(jù)文章來源地址http://www.zghlxwxcb.cn/news/detail-775190.html
到了這里,關(guān)于解決:element ui表格表頭自定義輸入框單元格el-input不能輸入問題的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!