Skip to main content

cancel

Description

Sets the function that closes a dropdown

Usage

oncancel?: (ev: MouseEvent) => void;

Parameters

  • ev - (object) a native HTML event object associated with the cancel action

Example

<script setup>
import { ref } from "vue";
import { Dropdown, Calendar, Text } from "@svar-ui/vue-core";

const popup = ref(false);

function oncancel() {
popup.value = false;
}
</script>

<template>
<div class="datepicker" @click="popup = true">
<Text />

<Dropdown v-if="popup" :oncancel="oncancel" position="top">
<Calendar :value="new Date(2023, 2, 15)" />
</Dropdown>
</div>
</template>

<style scoped>
.datepicker {
position: relative;
width: 300px;
}
</style>

Related article: Showing/hiding Dropdown