How do I get access to my properties with vue3, onMounted
function?
I'm using the setup script
tag:
<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
is not defined.
Why is this the case?
CodePudding user response:
Try this:
let props = withDefaults(defineProps<Props>(), {
configuration: () => ({}),
});
onMounted(() => {
console.log(props.configuration);
});