vue学习四,组件(慕课网学习笔记)

1.组件划分

功能模块:select,pagenation...

页面区域:header,footer,sidebar...

2.组件注册

header.vue和footer.vue文件,在App.vue中引用注册

import Header from './header'
import Footer from './footer'

new Vue({  
  components: { Header,Footer }
})

在内容中使用组件

3.组件通信

//this is header.vue(子组件)



child tell me:{{childWords}}

this.$emit():在它上面触发

this.$dispatch(): 由里向外传递,子向父

this.$boradcast(): 由外向里传递,广播,父向子


你可能感兴趣的:(前端技术)