美文网首页
组件之间的传值

组件之间的传值

作者: tenro | 来源:发表于2021-03-04 17:20 被阅读0次

    父组件调用子组件的方法:

    <Component id="name" />
    ** 在子组件里面声明 method **
    
    ** 在父组件里面调用method **
    this.selectComponent('#name').method();
    

    子组件调用父组件或父页面的方法

    ** 在父组件里面声明 method ,并将Component挂载在页面上 **
    <Component bind:test="method" />
    method(){
        console.log('子组件调用我')
    }
    
    ** 在子组件里面调用method **
    this.triggerEvent("test",{a:123})

    相关文章

      网友评论

          本文标题:组件之间的传值

          本文链接:https://www.haomeiwen.com/subject/jqmkqltx.html