Non-delivery methods Sons assembly

In the initialization of web app, main.js add a name to the data subject eventhub of empty vue. You can use this. $ Root.eventHub get the object.

Vue new new ({ 
    EL: '#app', 
    Router, 
    the render: H => H (the App), 
    Data: { 
        eventHub: new new Vue () 
    } 
}) 
call trigger event within the assembly
//. $ Root.eventHub get this object by the this 
// method call $ emit 
this. $ Root.eventHub. $ Emit ( 'eventName', data) 

calls the event of another component to accept, remove event listeners using the $ off method.
the this. $ root.eventHub. $ ON ( 'eventName', (Data) => { 
    // data processing 
})

Guess you like

Origin www.cnblogs.com/zhx119/p/11432971.html
Recommended