html (elementUi中的表格,传入位置和当前值)
methods(生成input,将当前输入的value值等于当前单元格的值)
handleChangeCorrectValue(index, data) {
var target = event.target,
$target = $(target),
attachElement = null;
$target.hide();
if (attachElement != null) {
attachElement.hide();
}
var input = document.createElement("input");
input.type = "text";
input.value = data;
input.setAttribute("style", "width:149px;height:48px;text-align:center;box-sizing:border-box;");
target.parentNode.insertBefore(input, target);
input.focus();
var _this = this;
input.onblur = function() {
if (this.value) {
_this.cloneCorrectNumTableData[index].questionCorrectValue = this.value;
} else {
this.value = data;
}
_this.cloneCorrectNumTableData[index].questionCorrectValue = this.value;
input.parentNode.removeChild(input);
$target.show();
if (attachElement != null) {
attachElement.show();
}
};
input.onkeypress = function(e) {
if (e.keyCode == 13) {
this.blur();
}
};
}