Subcomponents:
<Template>
<Button @ the Click = "ClickMe"> Click I </ Button>
</ Template>
<Script>
Export default {
Data () {
return {
Message: "I want to transfer data"
}
},
Methods: {
ClickMe () {
the this $ EMIT ( 'the Click-My', this.message).
}
}
}
</ Script>
parent element:
<Template>
<div ID = "App">
<Child-A @ MY- = the Click "the getMessage"> </ child-a>
<-! performed by a method of monitoring the parent component my-event event, then take the value of the passed subassembly ->
</ div>
</ Template>
<script>
import sonfrom './components/son.vue'
export default {
components: {
son
},
methods: {
getMessage(msg){
console.log(msg)
}
}
}
</script>
vue $ emit in use
Guess you like
Origin www.cnblogs.com/lovetl/p/11797543.html
Recommended
Ranking