f4b9da7cd223c7b5021e65f5302e3b3c10eb953858fa3d93650e7e13db6a98b23d2e813648705b89bc1089816df609899823839475029a3f5fa8cffee4e1f6 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <section :class="{'preview': !all, 'all': all}">
  3. <code class="language-html">
  4. <slot name="body"></slot>
  5. </code>
  6. <div class="show" @click="() => all = !all">{{ msg }}</div>
  7. </section>
  8. </template>
  9. <script>
  10. export default {
  11. data: function () {
  12. return {
  13. all: false
  14. }
  15. },
  16. computed: {
  17. msg () {
  18. return !this.all ? 'unfold' : 'fold'
  19. }
  20. }
  21. }
  22. </script>
  23. <style lang="css" scoped>
  24. section code.language-html {
  25. padding: 10px 20px;
  26. margin: 10px 0px;
  27. display: block;
  28. background-color: #333;
  29. color: #fff;
  30. overflow-x: auto;
  31. font-family: Consolas, Monaco, Droid, Sans, Mono, Source, Code, Pro, Menlo, Lucida, Sans, Type, Writer, Ubuntu, Mono;
  32. border-radius: 5px;
  33. white-space: pre;
  34. }
  35. .preview {
  36. position: relative;
  37. height: 150px;
  38. overflow: hidden;
  39. }
  40. .all{
  41. position: relative;
  42. }
  43. .show {
  44. position: absolute;
  45. width: 100%;
  46. text-align: center;
  47. left: 0;
  48. bottom: 0;
  49. line-height: 50px;
  50. height: 50px;
  51. cursor: pointer;
  52. background-color: rgba(255, 255, 255, 0.3);
  53. color: white;
  54. }
  55. </style>