How to make Vue js directive working in an appended html element

后端 未结 3 1085
轮回少年
轮回少年 2020-12-29 07:58

I have a Vue directive added in an appended html element like v-on directive but it\'s not working on my end. Basically I want to know the equivalent of .on() in jquery.

3条回答
  •  借酒劲吻你
    2020-12-29 08:28

    For Vue 2.x, the new solution is referenced here in the doc : https://vuejs.org/v2/api/#vm-mount (see 'Example').

    Custom example :

    var MyComponent = Vue.extend({
      template: '
    Hello!
    ', methods : { world : function() { console.log('world') } } }) var component = new MyComponent().$mount() document.getElementById('app').appendChild(component.$el)
    
    
    

    Works like a charm!

提交回复
热议问题