provide --- inject

父组件

provide () {

  const vm = this

  return {

    getinternalApi (api) {

      vm.audioapi = api

    }

  }

}

子组件

inject: [''getinternalApi]

 

computed: {

  if(typeof this.getinternalApi=== 'function'){

    this.getinternalApi({

      pause:this.pause.bind(this)

    })

  }

}

 

 

posted @ 2019-12-04 09:30  不服憋着  阅读(119)  评论(0编辑  收藏  举报