Skip to content

Vue 实用技巧

更新: 4/26/2024 字数: 0 字 时长: 0 分钟

Vue2 在父组件中监听子组件的生命周期钩子

vue
<template>
  <child @hook:mounted="onChildMounted"></child>
</template>
<script>
export default {
  methods: {
    onChildMounted() {},
  },
}
</script>

相关源码

methods 中使用 debounce / throttle

vue
<template>
  <div class="container" @click="handleClick"></div>
</template>
<script>
import { debounce } from 'lodash-es'
export default {
  methods: {
    handleClick: debounce(function () {}, 500),
  },
}
</script>

官网例子

如有转载或 CV 的请标注本站原文地址