# 組件如何使用
1,創建組件
2.注冊組件,在父組件的json文件中注冊
"usingComponents": {
"movie-item":"/components/movieItem/index"
}
3.使用組件
<movie-item></movie-item>
4.父組件向子組件傳參
Tip:通過子組件的屬性傳參,因為只有屬性是向父組件暴露的
<movie-item wx:for="{{movies}}" wx:key="{{index}}" movie="{{item}}"></movie-item>
5.要在子組件的properties屬性中注冊
properties: {
movie:{
type:Object
}
}
6.在子組件中使用父組件傳遞過來的數據
<text>{{movie.title}}</text>