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

54 lines
1.2 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>
import { Drawer, Button, Modal } from '@opentiny/vue'
export default {
components: {
TinyDrawer: Drawer,
TinyButton: Button
},
data() {
return {
visible: false,
placement: 'right'
}
},
methods: {
openDrawer(target) {
this.visible = true
this.placement = target === 'width' ? 'right' : 'bottom'
},
drag({ width, height }) {
Modal.message({ message: `抽屉的宽为${width},高为${height}`, status: 'info' })
}
}
}
</script>
<style scoped>
.content {
height: 300px;
padding: 16px 0;
}
</style>