{ "usingComponents": { "my-component": "../components/component/component", } }
<my-component id="myComponent"></my-component>
Page({ //... onLoad: function () { let myComponent = this.selectComponent(‘#myComponent‘); // 页面获取自定义组件实例 myComponent.componentInnerFunction(); // 通过实例调用组件事件 } //... })
Component({ //... methods: { componentInnerFunction: function() { console.log(‘i am inner function‘); } } //... })
原文:https://www.cnblogs.com/mmykdbc/p/11351491.html