Skip to content
On this page

useLogger

在控制台记录 vue 生命周期变化的 Hook。

Demo

Please open console
name: test
props.name: test
1
<template>
<div>
Please open console
<div>name: {{ name }}</div>
<button @click="setName('test1')">update props</button>
<Demo1 :name="name" />
</div>
</template>

<script lang="ts" setup>
import { useState } from 'v3-use'
import Demo1 from './demo1.vue'

// const props = defineProps({
// name: {
// type: String,
// default: 'test'
// }
// })
const [name, setName] = useState('test')
</script>

Usage

import { useLogger, useState } from 'v3-use'
useLogger('Demo', new Date().toLocaleDateString())
import { useLogger, useState } from 'v3-use'
useLogger('Demo', new Date().toLocaleDateString())

Reference

Type Declarations

export declare function useLogger(componentName: string, ...rest: any[]): void
export declare function useLogger(componentName: string, ...rest: any[]): void