useLifecycles


同时使用 onMountedonUnmountedHook

API

useLifecycles(onMountedCb, onUnmountedCb)

Params

参数名描述类型默认值
onMountedCbonMounted 时的回调() => any
onUnmountedCbonUnmounted 时的回调() => any

Example

请点击F12看log

Code

<script>
import { useLifecycles } from 'vue-compositions'
export default {
  setup() {
    useLifecycles(
      () => console.log('mounted'),
      () => console.log('unmounted')
    )
  }
}
</script>