AI写作智能体 自主规划任务,支持联网查询和网页读取,多模态高效创作各类分析报告、商业计划、营销方案、教学内容等。 广告
>### 1.创建组件 1.先建两个文件夹components--movieItem ![](https://box.kancloud.cn/17e800f932ec56df0d3d27c1593c0d5c_151x170.png) 2.在微信开发者工具中打开 ![](https://box.kancloud.cn/c95ebbf254904dc25138931d1c3b18b1_241x204.png) 命名为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> ~~~