lude1994

1.首先在父组件引入子组件,也需要json中引入

<alertMessage img="{{appMessage.imgSrc}}"></alertMessage>

2.子组件必须必须是Component,正常的是Page

 

3.在子组件中接收从父组件传来的属性

properties: {
    img: String,
    
},

4.在wxml中使用

 

<image src="{{img}}" />

5.完成。附上官方文档https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/component.html

 

分类:

技术点:

相关文章: