useLifecycles
同时使用 onMounted
和 onUnmounted
的 Hook
API
useLifecycles(onMountedCb, onUnmountedCb)
Params
参数名 | 描述 | 类型 | 默认值 |
---|---|---|---|
onMountedCb | onMounted 时的回调 | () => any | |
onUnmountedCb | onUnmounted 时的回调 | () => any |
Example
请点击F12看log
Code
<script>
import { useLifecycles } from 'vue-compositions'
export default {
setup() {
useLifecycles(
() => console.log('mounted'),
() => console.log('unmounted')
)
}
}
</script>