父组件调用子组件的方法:
<Component id="name" />
** 在子组件里面声明 method **
** 在父组件里面调用method **
this.selectComponent('#name').method();
子组件调用父组件或父页面的方法
** 在父组件里面声明 method ,并将Component挂载在页面上 **
<Component bind:test="method" />
method(){
console.log('子组件调用我')
}
** 在子组件里面调用method **
this.triggerEvent("test",{a:123})
网友评论