• 基于Vue2.0对Tinymce Editor富文本编辑器进行封装与使用


    前言

    这是一个展开和收起的小功能,可用于查看文章时点击展开和点击收起。

    一、示例代码

    (1)/src/views/Example/ExpandToggle/index.vue

    1. <script setup lang="ts">
    2. import { onMounted, ref } from "vue";
    3. import { ArrowUp, ArrowDown } from "@element-plus/icons-vue";
    4. const ewRef = ref(); // 实例
    5. const isExpand = ref(false); // 是否展开
    6. onMounted(() => {
    7. console.log('ewRef =>', ewRef)
    8. if (ewRef.value) {
    9. if (ewRef.value.scrollHeight > ewRef.value.clientHeight) {
    10. // ...
    11. }
    12. }
    13. });
    14. script>
    15. <style lang="less" scoped>
    16. .e-w {
    17. width: auto;
    18. padding: 100px;
    19. .e-w-main {
    20. height: 150px;
    21. overflow: hidden;
    22. position: relative;
    23. border: 1px solid #ddd;
    24. &.e-w-expand {
    25. height: auto;
    26. overflow: hidden;
    27. }
    28. // ---- ---- ---- ---- ^ 展开 样式 ---- ---- ---- ----
    29. .view-more {
    30. width: 100%;
    31. height: 22px;
    32. padding-top: 60px;
    33. background-image: linear-gradient(
    34. -180deg,
    35. rgba(255, 255, 255, 0) 0%,
    36. #ebebebf6 100%
    37. );
    38. position: absolute;
    39. bottom: 0;
    40. .view-more-box {
    41. width: 44px;
    42. height: 22px;
    43. background-color: rgba(255, 255, 255, 1);
    44. border-top-left-radius: 8px;
    45. border-top-right-radius: 8px;
    46. position: absolute;
    47. display: block;
    48. margin: auto;
    49. left: 0;
    50. right: 0;
    51. bottom: 0;
    52. cursor: pointer;
    53. .el-icon {
    54. position: absolute;
    55. display: block;
    56. margin: auto;
    57. left: 0;
    58. right: 0;
    59. bottom: 0;
    60. }
    61. }
    62. }
    63. // ---- ---- ---- ---- / 展开 样式 ---- ---- ---- ----
    64. // ---- ---- ---- ---- ^ 收起 样式 ---- ---- ---- ----
    65. .has-more {
    66. width: 100%;
    67. height: 22px;
    68. position: absolute;
    69. bottom: 0;
    70. .has-more-box {
    71. width: 44px;
    72. height: 22px;
    73. background-color: rgba(255, 255, 255, 1);
    74. border-top-left-radius: 8px;
    75. border-top-right-radius: 8px;
    76. position: absolute;
    77. display: block;
    78. margin: auto;
    79. left: 0;
    80. right: 0;
    81. bottom: 0;
    82. cursor: pointer;
    83. .el-icon {
    84. position: absolute;
    85. display: block;
    86. margin: auto;
    87. left: 0;
    88. right: 0;
    89. bottom: 0;
    90. }
    91. }
    92. }
    93. // ---- ---- ---- ---- / 收起 样式 ---- ---- ---- ----
    94. }
    95. }
    96. style>

    二、运行效果

  • 相关阅读:
    基于SpringBoot+Vue的婚恋相亲交友系统
    Zabbix监控硬盘S.M.A.R.T.信息教程
    基于SSM和layUI的汽车租赁系统设计
    STM32day2
    Python爬虫——Requests 的Get和Post请求
    YOLOv5 + Flask + Vue实现基于深度学习算法的垃圾检测系统源码+数据库
    前端设计模式应用
    Java基础-异常处理
    什么是JSF AV C++编码规范?
    字符串拼接你真的啥都知道了吗
  • 原文地址:https://blog.csdn.net/Cai181191/article/details/127755124