微信小程序-父子组件通信

父子组件通信

全局组件和局部组件的区别
父传子 properties
子传父 triggerEvent

插槽

子组件js文件内,配置支持插槽

Component({
  options: {
    multipleSlots: true // 在组件定义时的选项中启用多slot支持
  }
})

在组件内的wxml文件内,写入插槽

// first.wxml
<slot name="head"></slot>
view  
<slot name="foot"></slot>

在父组件内的子组件标签内调用

// index.html
<first>
   <view slot="head">123</view>
   <view slot="foot">123</view>
</first>
原文地址:https://www.cnblogs.com/ycyc123/p/14803639.html