How to call the method of slot

Mobile projects need to have a pull-up, load, pull-down and refresh function, which can be done through mint-ui.
if there are multiple pages, there will be more duplicate code, so you want to make it into a component, pass in the rendered content, and accept

through slot in the component.

when the paging component pulls down or up, it wants to request data by calling the corresponding method in the slot area (that is, the component where the incoming data resides), and ask various experts how to implement
call paginator

.
<template>
  <div id="app">
    <paginator>
      <ol>
        <h1>pupil</h1>
      </ol>
    </paginator>
  </div>
</template>

<script>
import paginator from "./pages/paginator.vue"
export default {
  components: {
    paginator
  },
  methods: {
    show () {
      alert("show")
    }
  }
}
</script>

declare paginator

<template>
  <div>
    temp
    <slot ref="one"></slot>
    <button @click="father"></button>
  </div>
</template>
<script>
export default {
  methods: {
    father () {
      console.log("father")
    }
  }
}
</script>
Sep.28,2021

access methods in the subcomponent instance with vm.$refs.child.method
reference
https://cn.vuejs.org/v2/api/-sharpref
ide/components-edge-cases.html-sharp%E8%AE%BF%E9%97%AE%E5%AD%90%E7%BB%84 E4%BB%B6%E5%AE%9E%E4%BE%8B%E6%88%96%E5%AD%90%E5%85%83%E7%B4%A0 "rel=" nofollow noreferrer "> https://cn.vuejs.org/v2/guide.

Menu