vue 子组件传值父组件 emit
<div id="app">
{{ message }} {{ books }}
<children_fei :children_message="message" :children_books="books"></children_fei>
</div>
<template id="children_foo"> <!-- 子组件 -->
<div> {{ children_message }} {{ children_books }} </div>
</template>
<script src="vue.js"></script>
<script>
const children_fei = {
template:'#children_foo',
props:{
children_message: String,
children_books: Array
}
};
const app = new Vue({
el: '#app',
data(){
return {
message: 'Hello Fei!',
books: ['论语', '史记', '左传', '汉书', '战国策']
}
},
components:{
children_fei
}
});
</script>