fix(页面布局): 修复文本溢出问题并优化导航栏显示逻辑

添加CSS样式防止文本溢出容器
修改PageTop组件导航栏显示条件
移除多余空行
This commit is contained in:
34701892@qq.com 2025-11-06 19:25:23 +08:00
parent c0a6629310
commit 69aec22ab6
3 changed files with 28 additions and 5 deletions

View File

@ -2,22 +2,23 @@
<view class="page_top"> <view class="page_top">
<view class="r_menu"> <view class="r_menu">
<image src="@/assets/images/logo.png" class="logo"></image> <image src="@/assets/images/logo.png" class="logo"></image>
<view class="r_menu_item" @click="tabChange(1)">
<view class="r_menu_item" @click="tabChange(1)" v-if="tabIndex != 4">
<text class="menu_item">资讯头条榜</text> <text class="menu_item">资讯头条榜</text>
<view class="line" v-if="tabIndex == 1"></view> <view class="line" v-if="tabIndex == 1"></view>
</view> </view>
<view class="r_menu_item" @click="tabChange(2)"> <view class="r_menu_item" @click="tabChange(2)" v-if="tabIndex != 4">
<text class="menu_item">热门行业</text> <text class="menu_item">热门行业</text>
<view class="line" v-if="tabIndex == 2"></view> <view class="line" v-if="tabIndex == 2"></view>
</view> </view>
<view class="r_menu_item" @click="tabChange(3)"> <view class="r_menu_item" @click="tabChange(3)" v-if="tabIndex != 4">
<text class="menu_item">风口概念</text> <text class="menu_item">风口概念</text>
<view class="line" v-if="tabIndex == 3"></view> <view class="line" v-if="tabIndex == 3"></view>
</view> </view>
<view class="r_menu_item" @click="tabChange(4)"> <view class="r_menu_item" @click="tabChange(4)" v-if="tabIndex == 4">
<text class="menu_item">编辑精选</text> <text class="menu_item">编辑精选</text>
<view class="line" v-if="tabIndex == 4"></view> <view class="line" v-if="tabIndex == 4"></view>
</view> </view>
@ -34,6 +35,7 @@ import { ref, onMounted, onUnmounted, reactive } from "vue";
import { onLoad, onShow } from "@dcloudio/uni-app"; import { onLoad, onShow } from "@dcloudio/uni-app";
import { Session } from "@/utils/storage"; import { Session } from "@/utils/storage";
const tabIndex = ref(0); const tabIndex = ref(0);
function tabChange(type) { function tabChange(type) {
// tabIndex.value = index; // tabIndex.value = index;

View File

@ -65,6 +65,7 @@ import { fetchArticleDetail } from "@/api/detail";
import LoginPopup from "@/components/loginPopup/index.vue"; import LoginPopup from "@/components/loginPopup/index.vue";
import { Session } from "@/utils/storage"; import { Session } from "@/utils/storage";
function goBack() { function goBack() {
// uni.navigateBack(); // uni.navigateBack();
@ -243,6 +244,8 @@ const handlePopupErrorCallback = () => {
border-radius: 20rpx; border-radius: 20rpx;
margin-top: 50rpx; margin-top: 50rpx;
} }
.r_tag_two { .r_tag_two {

View File

@ -1,6 +1,6 @@
<template> <template>
<view class="pc_all"> <view class="pc_all">
<PageTop></PageTop> <PageTop :pageType="pageType"></PageTop>
<view class="content" :style="{ filter: Session.get('token') ? '' : 'blur(5px)' }"> <view class="content" :style="{ filter: Session.get('token') ? '' : 'blur(5px)' }">
<view class="top_title"> <view class="top_title">
@ -270,6 +270,24 @@ const handlePopupErrorCallback = () => {
font-size: 16px; font-size: 16px;
color: #333333; color: #333333;
margin-top: 20rpx; margin-top: 20rpx;
/* 必须:限制内容不溢出容器 */
overflow: hidden;
/* 必须:超出部分显示省略号 */
text-overflow: ellipsis;
/* 必须将元素设置为webkit弹性盒模型用于控制行数 */
display: -webkit-box;
/* 关键限制显示的行数这里设为2行 */
-webkit-line-clamp: 2;
/* 必须:设置弹性盒的排列方向为垂直(让文本换行) */
-webkit-box-orient: vertical;
/* 可选调整行高和容器高度确保刚好容纳2行文本 */
line-height: 1.5;
/* 行高 */
max-height: 3em;
/* 2行总高度 = 行高 × 21.5×2=3 */
} }
} }