You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
1.8 KiB

4 months ago
  1. <script setup>
  2. import { ref } from 'vue'
  3. // 新闻飘屏数据
  4. const newsList = ref(Array(10).fill().map((_, i) => ({
  5. title: `每日资讯 ${i + 1}`,
  6. content: `资讯 ${i + 1} 的详细内容...`
  7. })))
  8. // 弹窗控制
  9. const dialogVisible = ref(false)
  10. const currentNews = ref('')
  11. const showNews = (news) => {
  12. currentNews.value = news
  13. dialogVisible.value = true
  14. }
  15. </script>
  16. <template>
  17. <div class="news-container">
  18. <el-text v-for="(news, index) in newsList" :key="index" class="news-item" @click="showNews(news)">
  19. {{ news.title }}
  20. </el-text>
  21. <el-text class="daily-item">
  22. <span></span>
  23. <span class="purple-text">每日复盘</span>
  24. <span> 即将上线</span>
  25. <br>
  26. <span>敬请期待</span>
  27. </el-text>
  28. </div>
  29. <!-- 新闻弹窗 -->
  30. <el-dialog v-model="dialogVisible" title="每日资讯详情" width="60%" >
  31. <p>{{ currentNews.content }}</p>
  32. </el-dialog>
  33. </template>
  34. <style scoped>
  35. .news-container {
  36. height: auto;
  37. display: flex;
  38. flex-direction: column;
  39. align-items: center;
  40. /* 水平居中 */
  41. gap: 10px;
  42. }
  43. .news-item {
  44. width: 60%;
  45. /* 拉长宽度 */
  46. padding: 10px;
  47. border: 2px solid #af84e0 !important;
  48. /* 紫色边框 */
  49. border-radius: 4px;
  50. text-align: center;
  51. /* 文字居中 */
  52. font-size: 18px;
  53. font-weight: bold;
  54. color: #000;
  55. }
  56. /* 响应式调整 */
  57. @media (max-width: 768px) {
  58. .news-item {
  59. width: 60%;
  60. font-size: 16px;
  61. }
  62. }
  63. .purple-text {
  64. color: #7315df !important;
  65. }
  66. .daily-item {
  67. font-size: 20px;
  68. font-weight: bold;
  69. line-height: 1.8;
  70. white-space: nowrap;
  71. text-align: center;
  72. /* 保持首行不换行 */
  73. }
  74. </style>