>### 1.創建組件
1.先建兩個文件夾components--movieItem

2.在微信開發者工具中打開

命名為index
>### 1.2注冊組件,在父組件的json文件中注冊
~~~
{
"usingComponents": {
"movie-item":"/components/movieItem/index"
}
}
~~~
>### 1.3使用組件
~~~
<movie-item></movie-item>
~~~
>### 1.4父組件向子組件傳參
>#### Tip:通過子組件的屬性傳參,因為只有屬性是向父組件暴露的
~~~
<view class="container">
<movie-item wx:for="{{movies}}" wx:key="{{index}}" movie="{{item}}"></movie-item>
</view>
~~~
>### 1.5要在子組件的`properties`屬性中注冊
~~~
Component({
/**
* 組件的屬性列表
*/
properties: {
movie:{
type:Object
}
},
/**
* 組件的初始數據
*/
data: {
},
/**
* 組件的方法列表
*/
methods: {
}
})
~~~
>### 1.6在子組件中使用父組件傳遞過來的數據
~~~
<view class="container">
<image src="{{movie.imageUrl}}"></image>
<text>{{movie.title}}</text>
<view>評分<text class="text">{{movie.average}}</text></view>
</view>
~~~