docs(Popover): fix placement demo (#11245)

This commit is contained in:
neverland 2022-11-12 13:23:44 +08:00 committed by GitHub
parent 4e9c301012
commit 9b513311c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,10 +1,13 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from 'vue'; import { ref } from 'vue';
import VanPopover, { PopoverPlacement } from '..'; import VanPopover, { type PopoverPlacement } from '..';
import VanButton from '../../button'; import VanButton from '../../button';
import VanField from '../../field'; import VanField from '../../field';
import VanPopup from '../../popup'; import VanPopup from '../../popup';
import VanPicker from '../../picker'; import VanPicker, {
PickerConfirmEventParams,
type PickerOption,
} from '../../picker';
import VanGrid from '../../grid'; import VanGrid from '../../grid';
import VanGridItem from '../../grid-item'; import VanGridItem from '../../grid-item';
import { showToast } from '../../toast'; import { showToast } from '../../toast';
@ -61,7 +64,7 @@ const t = useTranslate({
}, },
}); });
const placements = [ const placements: PickerOption[] = [
'top', 'top',
'top-start', 'top-start',
'top-end', 'top-end',
@ -74,7 +77,7 @@ const placements = [
'bottom', 'bottom',
'bottom-start', 'bottom-start',
'bottom-end', 'bottom-end',
]; ].map((item) => ({ text: item, value: item }));
const show = ref({ const show = ref({
showIcon: false, showIcon: false,
@ -98,10 +101,10 @@ const onClickChoosePlacement = () => {
}, 300); }, 300);
}; };
const onPickerChange = (value: PopoverPlacement) => { const onPickerChange = (option: PickerConfirmEventParams) => {
setTimeout(() => { setTimeout(() => {
show.value.placement = true; show.value.placement = true;
currentPlacement.value = value; currentPlacement.value = option.selectedValues[0] as PopoverPlacement;
}); });
}; };