Home  >  Q&A  >  body text

javascript - How to actively trigger the change event of the checkbox component in the ElementUI library of Vue.js?

Work on a project and encounter an actual scenario.
First level: a checkbox_1 (for example, bound to the change event method cevt1). After triggering, select all items in the second-level checkboxgroup (normal use) .

The problem is, when checkbox_2 of the checkboxgroup in the second level (for example, the checkbox of the sub-level is bound to the change event method cevt2) is selected, it should normally trigger all checkbox_3 selected in the corresponding checkboxgroup of the third level. ,

In fact, when checkbox_1 in the first level is triggered, cevt1 is triggered normally, but it is found that the change event cevt2 bound to checkbox_2 in the "second level" has not been called. Is there any solution?

伊谢尔伦伊谢尔伦2694 days ago2475

reply all(3)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-06-28 09:25:06

    Vue's change method seems to only respond to data changes caused by clicks and v-bind data binding. Other data changes will not trigger the change event. You can try to use the $emit method to manually call checkbox_2's change event.

    See:
    https://cn.vuejs.org/v2/api/#...

    reply
    0
  • 世界只因有你

    世界只因有你2017-06-28 09:25:06

    Try using watch to listen for changes in the value bound to the checkbox

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-28 09:25:06

    /q/10... Can you give a more detailed answer to this post? What is stored in the store from the router? ? Newbie

    reply
    0
  • Cancelreply