常规

  1. <!-- Child -->
  2. <script>
  3. export default {
  4. mounted () {
  5. this.$emit('onMounted')
  6. }
  7. }
  8. </script>
  9. <!-- Parent -->
  10. <template>
  11. <Child @onMounted="handleOnMounted" />
  12. </template>

@hook:mount

还有另一种简单的解决方案,你可以改用 @hook:mount@hook:mount

  1. <!-- Parent -->
  2. <template>
  3. <Child @hook:mounted="handleOnMounted" />
  4. </template>