微信小程序> 小程序子组件传值(triggerEvent)

小程序子组件传值(triggerEvent)

浏览量:2407 时间: 来源:周家大小姐.

需求,把A子组件的值传给父组件,在通过父组件传给子组件接收

A子组件

js: data

  /**     * 组件的属性列表     */    properties: {        hideBaitiao: {            type: Boolean,            // 默认隐藏            value: true        },        baitiao: { // 分期内容的数据            type: Array,        }    },        data: {        selectIndex:0    },     makeBaitiao(){//立即打白条            // 取到点击的具体下标            let selectIndex = this.data.baitiao[this.data.selectIndex]            // 点击事件带参传入父级            this.triggerEvent('updataSelect',selectIndex)        }

父组件 

html:接收

   !-- 白条弹框 --  IOU bind:updataSelect="selectItem"/IOU

js:赋值

   selectItem(e){//点击立即打白条,获取子组件传过来的值        console.log(e.detail.desc)//可以从e中得到传过来信息        let updaSelectItem = e.detail;        this.setData({            baitiaoSelectItem: e.detail        })    },

 

版权声明

即速应用倡导尊重与保护知识产权。如发现本站文章存在版权问题,烦请提供版权疑问、身份证明、版权证明、联系方式等发邮件至197452366@qq.com ,我们将及时处理。本站文章仅作分享交流用途,作者观点不等同于即速应用观点。用户与作者的任何交易与本站无关,请知悉。

产品经理

手机 : 13312967497

擅长 : 小程序流量变现

扫码领取礼包

最新资讯

热门模板

  • 头条
  • 搜狐
  • 微博
  • 百家
  • 一点资讯
  • 知乎