item-note左右对齐

本文探讨了在Ionic框架中遇到的项注对齐问题,并提供了相应的HTML代码示例。通过对代码片段的分析,可以帮助开发者更好地理解如何解决类似布局问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

            <div class="list list-inset">
                <label class="item item-input">
                    <span class="input-label">Address</span>
                    <input type="text" placeholder="Current Location">
                </label>
                <a class="item item-input item-icon-right" href="#/tab/category">
                    <span class="input-label">Category</span>
                    <span class="item-note">nihao</span>
                    <i class="icon ion-chevron-right"></i>
                </a>
            </div>

这里写图片描述

            <div class="list list-inset">
                <label class="item item-input">
                    <span class="input-label">Address</span>
                    <input type="text" placeholder="Current Location">
                </label>
                <a class="item item-icon-right" href="#/tab/category">
                    Category
                    <span class="item-note">nihao</span>
                    <i class="icon ion-chevron-right"></i>
                </a>
            </div>

文章摘自:https://forum.ionicframework.com/t/item-note-alignment/18896

<template> <view class="container"> <!-- 轮播图区域 --> <view class="swiper_area"> <SCSwiper :images="bannerImages"></SCSwiper> </view> <!-- 诉求分类 --> <view class="category_area"> <view v-if="loadingCategories" class="loading">加载分类中...</view> <uni-segmented-control v-else :values="categoryNames" @clickItem="changeCategory" styleType="text" :current="currentCategoryIndex"></uni-segmented-control> </view> <!-- 诉求列表 --> <view class="appeal_list"> <view v-if="loadingAppeals" class="loading">加载诉求中...</view> <view v-else> <uni-list> <uni-list-item v-for="item in currentAppeals" :key="item.id" :title="item.title" :note="`${item.appealCategoryName || '未分类'} | ${item.stateText}`" :thumb="item.imgUrl ? (ip + item.imgUrl) : ''" thumb-size="lg" :right-text="item.stateText" @click="viewAppealDetail(item.id)"> <template v-slot:footer> <view class="list-footer"> <text class="time">{{ formatDate(item.createTime) }}</text> </view> </template> </uni-list-item> </uni-list> <!-- 无数据提示 --> <view v-if="currentAppeals.length === 0" class="no_data"> 暂无诉求数据 </view> </view> </view> <!-- 底部操作按钮 - 关键修复 --> <view class="nav_actions"> <button class="create_btn" @click="createAppeal">创建诉求</button> <button class="my_btn" @click="viewMyAppeals">我的诉求</button> </view> </view> </template> <script setup> import { ref, onMounted } from 'vue' import { ip, getHttp } from '../../utils/http.js' // 轮播图数据 const bannerImages = ref([]) // 诉求分类数据 const appealCategories = ref([]) const categoryNames = ref([]) const currentCategoryIndex = ref(0) // 当前显示的诉求列表 const currentAppeals = ref([]) // 加载状态 const loadingCategories = ref(true) const loadingAppeals = ref(true) // 状态码转文本函数 const getStateText = (state) => { const stateMap = { '0': '待处理', '1': '处理中', '2': '已解决', '3': '已关闭' } return stateMap[state] || '未知状态' } // 格式化日期 const formatDate = (timestamp) => { if (!timestamp) return ''; const date = new Date(timestamp); return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`; } // 获取广告轮播图 async function getBanners() { try { const res = await getHttp({ url: '/prod-api/api/gov-service-hotline/ad-banner/list' }) // 统一处理响应结构 const data = res.data?.code === 200 ? res.data.data : res.code === 200 ? res.data : []; if (Array.isArray(data)) { bannerImages.value = data.map(item => ip + item.imgUrl) } } catch (error) { console.error('获取轮播图失败:', error) } } // 获取诉求分类 async function getAppealCategories() { try { loadingCategories.value = true const res = await getHttp({ url: '/prod-api/api/gov-service-hotline/appeal-category/list' }) // 统一处理响应结构 const data = res.data?.code === 200 ? (res.data.rows || res.data.data) : res.code === 200 ? (res.rows || res.data) : []; if (Array.isArray(data)) { appealCategories.value = data categoryNames.value = data.map(item => item.name) // 默认加载第一个分类的诉求 if (data.length > 0) { getAppealsByCategory(data[0].id) } } } catch (error) { console.error('获取诉求分类失败:', error) uni.showToast({ title: '获取分类失败', icon: 'none' }) } finally { loadingCategories.value = false } } // 根据分类获取诉求 async function getAppealsByCategory(categoryId) { try { loadingAppeals.value = true const res = await getHttp({ url: '/prod-api/api/gov-service-hotline/appeal/list', data: { appealCategoryId: categoryId, pageNum: 1, pageSize: 10 } }) // 统一处理响应结构 const data = res.data?.code === 200 ? (res.data.rows || res.data.data) : res.code === 200 ? (res.rows || res.data) : []; if (Array.isArray(data)) { currentAppeals.value = data.map(item => ({ ...item, stateText: getStateText(item.state) })) } } catch (error) { console.error('获取诉求列表失败:', error) uni.showToast({ title: '获取诉求列表失败', icon: 'none' }) } finally { loadingAppeals.value = false } } // 分类切换处理 - 修复事件处理 function changeCategory(e) { const index = e.currentIndex; if (index >= 0 && index < appealCategories.value.length) { currentCategoryIndex.value = index const category = appealCategories.value[index] getAppealsByCategory(category.id) } } // 查看诉求详情 function viewAppealDetail(id) { uni.navigateTo({ url: `/pages/index/AppealDetail?id=${id}` }) } // 创建诉求 function createAppeal() { uni.navigateTo({ url: '/pages/index/CreateAppeal' }) } // 查看我的诉求 function viewMyAppeals() { uni.navigateTo({ url: '/pages/index/MyAppeals' }) } onMounted(() => { getBanners() getAppealCategories() }) </script> <style lang="scss" scoped> .container { padding: 20rpx; background-color: #f5f5f5; .loading { padding: 30rpx; text-align: center; color: #888; font-size: 28rpx; } .swiper_area { height: 350rpx; margin-bottom: 30rpx; border-radius: 15rpx; overflow: hidden; box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); } .category_area { margin-bottom: 30rpx; background: #fff; border-radius: 15rpx; padding: 20rpx 10rpx; min-height: 80rpx; box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); } .appeal_list { margin-bottom: 120rpx; :deep(.uni-list-item__container) { padding: 24rpx 30rpx; } :deep(.uni-list-item__content-title) { font-size: 32rpx; font-weight: bold; margin-bottom: 10rpx; } :deep(.uni-list-item__content-note) { color: #666; font-size: 26rpx; margin-top: 8rpx; } :deep(.uni-list-item__extra-text) { font-size: 26rpx; color: #007AFF; } .list-footer { margin-top: 10rpx; .time { font-size: 24rpx; color: #999; } } .no_data { text-align: center; padding: 80rpx 40rpx; color: #999; font-size: 30rpx; background: #fff; border-radius: 15rpx; } } /* 固定在导航栏上方的按钮 */ .nav_actions { bottom: 0; left: 0; right: 0; display: flex; flex-direction: row; /* 明确设置为行布局 */ align-items: center; justify-content: space-between; /* 使用空间分布对齐 */ padding: 15rpx 30rpx; background: #fff; border-top: 1rpx solid #e0e0e0; border-radius: 10rpx; box-shadow: 0 -4rpx 12rpx rgba(0, 0, 0, 0.05); /* 安全区域适配 */ padding-bottom: calc(15rpx + constant(safe-area-inset-bottom)); padding-bottom: calc(15rpx + env(safe-area-inset-bottom)); z-index: 1000; box-sizing: border-box; /* 确保内边距包含在宽度内 */ /* 安全区域占位 */ &::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: constant(safe-area-inset-bottom); height: env(safe-area-inset-bottom); background: #fff; } button { flex: 1; /* 等分空间 */ min-width: 0; /* 允许内容收缩 */ margin: 0 15rpx; /* 左右间距 */ font-size: 30rpx; height: 80rpx; line-height: 80rpx; border-radius: 50rpx; position: relative; z-index: 2; box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1); transition: all 0.2s; display: flex; /* 内部使用flex */ align-items: center; /* 垂直居中 */ justify-content: center; /* 水平居中 */ /* 安全区域适配 */ margin-bottom: constant(safe-area-inset-bottom); margin-bottom: env(safe-area-inset-bottom); overflow: hidden; /* 防止内容溢出 */ /* 创建诉求按钮 - 蓝色风格 */ &.create_btn { background: #007AFF; /* 纯蓝色背景 */ color: white; border: none; /* 点击效果 */ &:active { background: #0062cc; transform: scale(0.98); box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1); } } /* 我的诉求按钮 - 白色风格 */ &.my_btn { background: #ffffff; color: #333; border: 1rpx solid #e0e0e0; /* 点击效果 */ &:active { background: #f8f8f8; transform: scale(0.98); box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1); } } } } } </style> 把 诉求分类栏 改成文字横向显示
最新发布
06-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值