tiny-vue/examples/sites/demos/pc/app/drawer/dragable-composition-api.vue

45 lines
1.1 KiB
Vue

<template>
<div>
<tiny-button @click="openDrawer('width')" type="primary"> 宽度拖拽 </tiny-button>
<tiny-button @click="openDrawer('height')" type="primary"> 高度拖拽 </tiny-button>
<tiny-drawer
:placement="placement"
title="标题"
dragable
:visible="visible"
@update:visible="visible = $event"
@drag="drag"
>
<div class="content">
<p v-if="placement === 'right'">横向拖拽左边框可改变抽屉主体宽度</p>
<p v-else>竖向拖拽上边框可改变抽屉主体高度</p>
</div>
</tiny-drawer>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { Drawer as TinyDrawer, Button as TinyButton, Modal } from '@opentiny/vue'
const visible = ref(false)
const placement = ref('right')
const openDrawer = (target) => {
visible.value = true
placement.value = target === 'width' ? 'right' : 'bottom'
}
const drag = ({ width, height }) => {
Modal.message({ message: `抽屉的宽为${width},高为${height}`, status: 'info' })
}
</script>
<style scoped>
.content {
height: 300px;
padding: 16px 0;
}
</style>