Props and Emit
Passing Data with Props
Prop
<template>
<div class="parent">
<h2>Parent Component</h2>
<!-- 1. prop name="content" -->
<Child @hungry="onHungrySignal" :propFromParent="parentMsg" />
<!-- The custom event that the child $emit-ted is 'hungry' -->
</div>
</template>
<script>
// 1. import
import Child from '../components/Child.vue'
export default {
name: 'Parent',
data(){
return {
parentMsg: 'Message from parent',
}
},
// 2. Register
components: {
Child, // This is a shorthand for Child: Child!
},
methods: {
onHungrySignal(menu1, menu2){
console.log(menu1, menu2)
}
}
}
</script>
<style>
</style>camelCase vs kebab-case
camelCase vs kebab-caseLiteral vs Dynamic
Literal vs DynamicOne-way Data Flow
Event Emit
Event Emission Code Format
Building a Youtube Browser
1. Get Youtube API key from Google Developer Console
2. Install axios
axios3. Understand usage through official documentation
vue-filter
Last updated