Vue

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

<template>
  <child @hook:mounted="onChildMounted"></child>
</template>
<script>
export default {
  methods: {
    onChildMounted() {}
  }
}
</script>
1
2
3
4
5
6
7
8
9
10

相关源码open in new window

在 methods 中使用 debounce / throttle

<template>
  <div class="container" @click="handleClick"></div>
</template>
<script>
import { debounce } from 'lodash-es'
export default {
  methods: {
    handleClick: debounce(function () {}, 500)
  }
}
</script>
1
2
3
4
5
6
7
8
9
10
11

官网例子open in new window

上次更新: 9/7/2021, 3:46:25 PM
(adsbygoogle = window.adsbygoogle || []).push({});