Vue3 onMounted 道具未定义

Vue3 onMounted props not defined

如何使用 vue3、onMounted 函数访问我的属性?

我正在使用 setup script 标签:

<script lang="ts" setup>
import { ref, onMounted, computed, defineEmits, defineComponent } from "vue";

defineComponent({
  name: "DatePicker",
});

interface Props {
  configuration: object;
}

withDefaults(defineProps<Props>(), {
  configuration: () => ({}),
});

onMounted(() => {
  console.log(configuration);
});
</script>

configuration 未定义。

为什么会这样?

试试这个:

let props = withDefaults(defineProps<Props>(), {
  configuration: () => ({}),
});

onMounted(() => {
  console.log(props.configuration);
});