{"usingComponents": {"comm-scroll":"../components/rollingLoad/rollingLoad"}}
<comm-scroll></comm-scroll>
Component({/*** 组件的属性列表*/properties: {sourceData:{type:Object,value:{name:'阿明',value:'18'}}},/*** 组件的初始数据*/data: {},/*** 组件的方法列表*/methods: {// 子组件函数getChildFuc(){console.log('父组件调子组件函数');},}});
<view catchtap="getChild">调子组件</view><comm-scroll id="my"></comm-scroll>
// 父组件调子组件函数getChild(){let myCom = this.selectComponent("#my");myCom.getChildFuc();console.log(myCom.data.sourceData);},

<comm-scroll id="my" scrollH="{{heightTest}}" bind:componentFun="pageFun"></comm-scroll>
/*** 页面的初始数据*/data: {heightTest:50, //父组件属性},// 父组件函数pageFun(){console.log('子组件调父组件函数');},
<scroll-view scroll-y="{{true}}" style="height: {{scrollH}}vh;" enable-back-to-top='true'><view catchtap="toParentFuc">父组件属性:{{scrollH}}</view></scroll-view>

// 子组件调父组件函数toParentFuc(){this.triggerEvent("componentFun", {});},

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号