index.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <div>
  3. <el-card class="box-card" shadow="never">
  4. <div>
  5. <el-card v-for="(t, index) in tricks" :key="index" class="chlid-box-card" shadow="hover">
  6. <div slot="header" class="cardHeader">
  7. 段落模板:<el-tag effect="plain">{{ t.name }}</el-tag>
  8. </div>
  9. <p class="trick" v-if="removeHtmlTag(t.section) != null">{{ removeHtmlTag(t.section) }}
  10. <el-button plain @click="reference(t.section)">引用</el-button><el-button plain
  11. @click="prview(t.section)" type="primary">预览</el-button>
  12. </p>
  13. </el-card>
  14. </div>
  15. </el-card>
  16. <el-dialog :visible.sync="dialogTableVisible" width="60%" center>
  17. <div class="dialog-bg">
  18. <div class="like-word" v-html="htmlStr">
  19. </div>
  20. </div>
  21. </el-dialog>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. props: {
  27. tricks: {
  28. type: Array,
  29. required: false,
  30. default: []
  31. },
  32. },
  33. computed: {
  34. },
  35. data() {
  36. return {
  37. dialogTableVisible: false,
  38. htmlStr: null,
  39. }
  40. },
  41. methods: {
  42. prview(htmlStr) {
  43. this.dialogTableVisible = true
  44. this.htmlStr = htmlStr;
  45. },
  46. removeHtmlTag(htmlStr) {
  47. if (htmlStr) {
  48. let content = htmlStr.replace(/<[^>]+>/g, "");
  49. return content.length > 80 ? (content.slice(0, 80) + '...') : (content);
  50. }
  51. else {
  52. return null;
  53. }
  54. },
  55. reference(section) {
  56. this.$emit('reference',section)
  57. }
  58. }
  59. }
  60. </script>
  61. <style scoped>
  62. .box-card {
  63. width: 750px;
  64. }
  65. .cardHeader {
  66. height: 20px;
  67. color: gray;
  68. }
  69. .chlid-box-card {
  70. width: 710px;
  71. height: 200px;
  72. margin-bottom: 30px;
  73. }
  74. .chlid-box-card:hover {
  75. color: black;
  76. cursor: pointer;
  77. font-weight: bold;
  78. }
  79. p {
  80. text-indent: 2em;
  81. color: gray;
  82. letter-spacing: 2px;
  83. line-height: 1.5
  84. }
  85. .dialog-bg {
  86. width: 100%;
  87. height: 700px;
  88. position: relative;
  89. overflow: scroll;
  90. }
  91. .like-word {
  92. width: 90%;
  93. height: auto;
  94. position: absolute;
  95. top: 20px;
  96. left: 0;
  97. right: 0;
  98. margin: auto;
  99. -moz-box-shadow: 3px 3px 4px rgb(255, 228, 227);
  100. -webkit-box-shadow: 3px 3px 4px rgb(255, 228, 227);
  101. box-shadow: 0 0 20px rgb(175, 175, 175);
  102. padding: 20px;
  103. }</style>