When element-ui uses msgbox to create an el-date-picker, the change event does not respond and the value cannot be bound.

let h = this.$createElement;

window.vm = this
this.$msgbox({
  message: h("el-date-picker", {
    domProps: {
      value: this.batch_change_time
    },
    on: {
      change: (e) => {
        this.batch_change_time = e
      }
    }
  })
})

the requirement is to pop up a msgbox to select the time.

now there are two problems:

  1. change will not trigger (input can)
  2. value does not seem to be bound to the component. The date selector content is still empty after the date selected

am I writing it wrong?

Jul.16,2021

  1. switching date or time will not trigger the change event, but clearing the date will trigger the change event. For more information, please see the source code of picker.vue .
  2. after testing, vnode, mounted through the message option of $msgbox cannot bind attributes in props, that is, it can only achieve one-way binding from the pop-up window vnode to the parent component (through the on input event, However, after the input event response date is changed, this change can no longer make the pop-up vnode respond. This is also related to the implementation of el-date-picker . If it can receive a v-model value of null , and does not directly rely on v-model , that is, the value attribute, then it can still be rescued. The way to solve this problem is to put a layer on el-date-picker and use the outer data to help el-data-picker manage value . But the cost of this solution already far outweighs the benefits of using $msgbox , so my final advice is. Give up

Hello, I have the same problem, have you solved it?

Menu