天天看点

python messagebox 自定义_使用Element-ui组件中MessageBox组件中自定义消息message中使用input输入框怎么绑定state中的值...

记录下解决的办法:

const h = this.$createElement;

let that = this;

this.$msgbox({

title: "扫码",

message: h("div", null, [

h("el-input", null, that.inputValue),

h("input", {

style: {

marginTop: "20px"

},

attrs: { value: that.inputValue, id:"hinput"},

on: {

input: this.handleClick

}

})

]),

showCancelButton: true,

confirmButtonText: "确定",

cancelButtonText: "取消",

beforeClose: (action, instance, done) => {

if (action === "confirm") {

instance.confirmButtonLoading = true;

instance.confirmButtonText = "执行中...";

setTimeout(() => {

done();

setTimeout(() => {

instance.confirmButtonLoading = false;

}, 300);

}, 3000);

} else {

done();

}

}

}).then(action => {

this.$message({

type: "info",

message: "action: " + action

});

});

handleClick(val) {

var a=document.getElementById("hinput").value;

this.inputValue = a

console.log(this.inputValue)

}

感觉不是最好的方法,但是反馈下