这篇文章主要介绍了微信小程序页面调用自定义组件内的事件详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
page
page.json
{ "usingcomponents": { "my-component": "../components/component/component", } }
page.wxml
<my-component id="mycomponent"></my-component>
page.js
page({ //... onload: function () { let mycomponent = this.selectcomponent('#mycomponent'); // 页面获取自定义组件实例 mycomponent.componentinnerfunction(); // 通过实例调用组件事件 } //... })
component
component.js
component({ //... methods: { componentinnerfunction: function() { console.log('i am inner function'); } } //... })
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
同事牛逼啊,写了个隐藏 bug,我排查了 3 天才解决问题!
【JavaScript笔记(一)】万丈高楼平地起 - 基本概念篇
轻松解决 org.apache.taglibs.standard.tlv.JstlCoreTLV 困惑
网友评论