drawer.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <el-radio-group v-model="direction">
  3. <el-radio label="ltr">left to right</el-radio>
  4. <el-radio label="rtl">right to left</el-radio>
  5. <el-radio label="ttb">top to bottom</el-radio>
  6. <el-radio label="btt">bottom to top</el-radio>
  7. </el-radio-group>
  8. <el-button type="primary" style="margin-left: 16px" @click="drawer = true">
  9. open
  10. </el-button>
  11. <el-button type="primary" style="margin-left: 16px" @click="drawer2 = true">
  12. with footer
  13. </el-button>
  14. <el-drawer v-model="drawer" title="I am the title" :direction="direction">
  15. <span>Hi, there!</span>
  16. </el-drawer>
  17. <el-drawer v-model="drawer2" :direction="direction">
  18. <template #title>
  19. <h4>set title by slot</h4>
  20. </template>
  21. <template #default>
  22. <div>
  23. <el-radio v-model="radio1" label="Option 1" size="large"
  24. >Option 1</el-radio
  25. >
  26. <el-radio v-model="radio1" label="Option 2" size="large"
  27. >Option 2</el-radio
  28. >
  29. </div>
  30. </template>
  31. <template #footer>
  32. <div style="flex: auto">
  33. <el-button @click="cancelClick">cancel</el-button>
  34. <el-button type="primary">confirm</el-button>
  35. </div>
  36. </template>
  37. </el-drawer>
  38. </template>
  39. <script lang="ts" setup>
  40. import { ref } from 'vue'
  41. const drawer = ref(false)
  42. const drawer2 = ref(false)
  43. const direction = ref<'rtl'>('rtl')
  44. const radio1 = ref('Option 1')
  45. function cancelClick() {
  46. drawer2.value = false
  47. }
  48. </script>