TextViewDialog.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <el-dialog v-model="dialogVisible" style="width:1200px;height:600px;" :title="props.title">
  3. <template #header>
  4. <div class="dialog-header">
  5. <span class="dialog-title">{{ props.title }}</span>
  6. </div>
  7. </template>
  8. <div class="dialog-body">
  9. <pre>{{ props.content }}</pre>
  10. </div>
  11. <template #footer>
  12. <div class="dialog-footer">
  13. <el-button @click="dialogVisible = false">取消</el-button>
  14. <el-button type="primary" @click="dialogVisible = false">
  15. 确定
  16. </el-button>
  17. </div>
  18. </template>
  19. </el-dialog>
  20. </template>
  21. <script setup lang="ts">
  22. import { ref, watch } from 'vue'
  23. const props = defineProps({
  24. title: { type: String, required: true, default: '文件内容' },
  25. content: { type: String, required: true, default: '文件内容' },
  26. })
  27. const emit = defineEmits(['update:modelValue'])
  28. const dialogVisible = ref(false)
  29. const showDialog = (visible: boolean = true) => {
  30. dialogVisible.value = visible
  31. }
  32. defineExpose({ showDialog })
  33. </script>
  34. <style scoped>
  35. .dialog-header {
  36. display: flex;
  37. justify-content: space-between;
  38. align-items: center;
  39. }
  40. .dialog-body {
  41. width: 100%;
  42. height: 450px;
  43. /* 可以根据需要调整 */
  44. overflow-y: auto;
  45. /* 当内容超出时显示滚动条 */
  46. text-wrap: wrap;
  47. word-wrap: normal;
  48. }
  49. .dialog-footer {
  50. display: flex;
  51. justify-content: flex-end;
  52. /* 按钮靠右对齐 */
  53. }
  54. </style>