SiteNotice.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <el-card class="box-card">
  3. <div slot="header" class="clearfix">
  4. <img src="@/assets/img/icon/speaker.png" alt="" class="recommand-icon">
  5. <span>站点公告</span>
  6. </div>
  7. <div class="text item" style="height: 20vh;">
  8. <el-scrollbar style="width: 100%; height: 100%;">
  9. <el-row>
  10. <span v-html="content" />
  11. </el-row>
  12. </el-scrollbar>
  13. </div>
  14. </el-card>
  15. </template>
  16. <script>
  17. import { getSiteNotice } from '@/api/content'
  18. export default {
  19. name: 'SiteNotice',
  20. data() {
  21. return {
  22. content: ''
  23. }
  24. },
  25. created() {
  26. getSiteNotice().then(resp => {
  27. if (resp.code === 0) {
  28. this.content = resp.data
  29. }
  30. }).catch(error => {
  31. this.$message.error(error.message)
  32. }).finally(() => {
  33. })
  34. },
  35. methods: {}
  36. }
  37. </script>
  38. <style scoped>
  39. @media screen and (max-width: 768px) {
  40. .clearfix span {
  41. font-size: 15px;
  42. position: absolute;
  43. bottom: 8px;
  44. left: 35px;
  45. }
  46. }
  47. .item {
  48. height: 25px;
  49. margin-top: 4px;
  50. margin-bottom: 16px;
  51. overflow: hidden;
  52. text-overflow: ellipsis;
  53. display: -webkit-box;
  54. -webkit-line-clamp: 1; /*行数*/
  55. -webkit-box-orient: vertical;
  56. }
  57. .clearfix:before,
  58. .clearfix:after {
  59. display: table;
  60. content: "";
  61. }
  62. .clearfix:after {
  63. clear: both;
  64. }
  65. .clearfix {
  66. position: relative;
  67. }
  68. .clearfix span {
  69. font-size: 20px;
  70. position: absolute;
  71. bottom: 8px;
  72. left: 35px;
  73. }
  74. .box-card {
  75. width: 100%;
  76. }
  77. .recommand-icon {
  78. width: 30px;
  79. }
  80. </style>