Flex:Label手型光标

本文介绍如何在Flex中为Label元素设置手型光标效果,通过三步操作即可实现:设置useHandCursor属性为true,mouseChildren属性为false,buttonMode属性为true。

在flex中,要让一个label应用手型光标如下:

 

label.useHandCursor = true;

label.mouseChildren = false;

label.buttonMode = true;

<template> <view class="container"> <!-- 登录区域 --> <view v-if="!isLoggedIn" class="login-box"> <view class="login-title">投诉后台管理登录</view> <input v-model="loginForm.username" placeholder="请输入账号" class="login-input" /> <input v-model="loginForm.password" placeholder="请输入密码" type="password" class="login-input" /> <button @click="login" class="login-button">登录</button> <button @click="goToHome" class="home-button">返回首页</button> <text v-if="loginError" class="login-error">{{ loginError }}</text> </view> <!-- 投诉列表区域 --> <view v-else class="complaint-container"> <view class="back-home" @click="goToHome"> <text class="icon">←</text> <text>返回首页</text> </view> <view class="search-bar"> <input v-model="searchForm.category" placeholder="请输入投诉类别" /> <input v-model="searchForm.keyword" placeholder="请输入关键词" /> <view class="dropdown"> <picker mode="selector" :range="statusOptions" range-key="label" :value="searchForm.statusIndex" @change="handleStatusPickerChange"> <view class="dropdown-trigger"> <text>{{ statusOptions[searchForm.statusIndex].label }}</text> <text class="arrow">▼</text> </view> </picker> </view> <button @click="searchComplaints">搜索</button> </view> <view class="complaint-list"> <view class="complaint-item" v-for="item in complaints" :key="item.id"> <view class="title">{{ item.title }}</view> <view class="category">类别:{{ item.category }}</view> <view class="status-container"> <text class="status-label">状态:</text> <picker mode="selector" :range="statusOptions" range-key="label" :value="item.statusIndex" @change="changeStatus($event, item)"> <view :class="['picker-button', getStatusClass(item.statusLabel)]"> <text>{{ item.statusLabel }}</text> </view> </picker> </view> </view> </view> </view> </view> </template> <script setup> import { ref, onMounted } from 'vue'; // 登录相关 const isLoggedIn = ref(false); const loginForm = ref({ username: '', password: '' }); const loginError = ref(''); // 页面加载时检查缓存 onMounted(() => { const cachedLogin = uni.getStorageSync('loginInfo'); if (cachedLogin) { isLoggedIn.value = true; loginForm.value.username = cachedLogin.username; loginForm.value.password = cachedLogin.password; fetchComplaints(); } }); // 返回首页 const goToHome = () => { try { const pages = getCurrentPages(); if (pages.length > 1) { uni.navigateBack(); } else { uni.reLaunch({ url: '/pages/index/index' }); } } catch (error) { uni.reLaunch({ url: '/pages/index/index' }); } }; // 搜索相关 const searchForm = ref({ category: '', keyword: '', statusIndex: 0 // 默认选中“待处理” }); // 投诉列表 const complaints = ref([]); // 状态选择器事件 const handleStatusPickerChange = (event) => { const index = event.detail.value; searchForm.value.statusIndex = index; }; // 状态选项 const statusOptions = ref([ { label: '待处理', value: 0 }, { label: '处理中', value: 1 }, { label: '已完成', value: 2 } ]); //状态颜色 const getStatusClass = (statusLabel) => { if (statusLabel === '待处理') return 'status-pending'; if (statusLabel === '处理中') return 'status-processing'; if (statusLabel === '已完成') return 'status-completed'; return ''; }; // 模拟登录接口 const login = async () => { uni.showLoading({ title: '登录中' }); // 模拟请求接口 setTimeout(() => { if (loginForm.value.username === '' && loginForm.value.password === '') { // 缓存登录信息 uni.setStorageSync('loginInfo', { username: loginForm.value.username, password: loginForm.value.password }); isLoggedIn.value = true; loginError.value = ''; fetchComplaints(); // 登录成功后加载投诉列表 } else { loginError.value = '账号或密码错误'; } uni.hideLoading(); }, 500); }; // 获取投诉列表(模拟) const fetchComplaints = async () => { uni.showLoading({ title: '加载中' }); // 模拟从后台获取数据 setTimeout(() => { complaints.value = [ { id: 1, title: '关于食堂卫生问题的投诉', category: '后勤管理', content: '食堂卫生不达标,影响员工健康', status: 0, statusLabel: '待处理', statusIndex: 0 }, { id: 2, title: '关于办公室空调噪音大', category: '设备问题', content: '空调运行噪音大,影响办公', status: 1, statusLabel: '处理中', statusIndex: 1 } ]; uni.hideLoading(); }, 500); }; // 搜索投诉 const searchComplaints = async () => { uni.showLoading({ title: '搜索中' }); setTimeout(() => { let filtered = complaints.value; // 按类别过滤 if (searchForm.value.category) { filtered = filtered.filter(item => item.category.includes(searchForm.value.category)); } // 按关键词过滤 if (searchForm.value.keyword) { filtered = filtered.filter(item => item.content.includes(searchForm.value.keyword)); } // 按状态过滤 const selectedStatusValue = statusOptions.value[searchForm.value.statusIndex].value; if (selectedStatusValue !== '') { filtered = filtered.filter(item => item.status === selectedStatusValue); } complaints.value = filtered; uni.hideLoading(); }, 300); }; // 状态变更 const changeStatus = async (event, item) => { const index = event.detail.value; const newStatus = statusOptions.value[index].value; item.status = newStatus; item.statusLabel = statusOptions.value[index].label; item.statusIndex = index; // 模拟提交到后台 await updateStatusToServer(item); uni.showToast({ title: '状态已更新' }); }; // 模拟提交到后台 const updateStatusToServer = async (item) => { return new Promise(resolve => { setTimeout(() => { resolve(); }, 300); }); }; </script> <style scoped> .container { padding: 30rpx; background-color: #f9f9f9; } .home-button { background-color: #f0f0f0; color: #333; margin-top: 20rpx; } .back-home { display: flex; align-items: center; font-size: 30rpx; color: #007AFF; padding: 10rpx 20rpx; border-radius: 8rpx; background-color: #f5f5f5; width: fit-content; /* 根据内容自适应宽度 */ cursor: pointer; /* PC端显示光标 */ margin-bottom: 20rpx; /* 增加底部间距 */ } .back-home .icon { margin-right: 10rpx; font-weight: bold; } .login-box { background-color: #fff; padding: 40rpx; border-radius: 16rpx; box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); } .login-title { font-size: 36rpx; font-weight: bold; text-align: center; margin-bottom: 40rpx; color: #333; } .login-input { border: 1rpx solid #ccc; padding: 20rpx; margin-bottom: 30rpx; border-radius: 8rpx; width: 100%; } .login-button { background-color: #007AFF; color: white; } .login-error { color: red; font-size: 24rpx; margin-top: 10rpx; display: block; } .search-bar input { border: 1rpx solid #ccc; padding: 20rpx; margin-bottom: 20rpx; border-radius: 8rpx; } .complaint-list { margin-top: 30rpx; } .complaint-item { background-color: #fff; padding: 30rpx; margin-bottom: 30rpx; border-radius: 12rpx; box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1); } .title { font-size: 32rpx; font-weight: bold; color: #333; margin-bottom: 20rpx; } .category { font-size: 28rpx; color: #666; margin-bottom: 20rpx; } .status { font-size: 28rpx; color: #999; } .status-container { display: flex; align-items: center; } .status-label { font-size: 28rpx; color: #999; } .picker-button { padding: 10rpx 20rpx; border-radius: 8rpx; font-size: 28rpx; color: white; } .status-pending { background-color: #ff9900; /* 橙色 */ } .status-processing { background-color: #007AFF; /* 蓝色 */ } .status-completed { background-color: #00cc66; /* 绿色 */ } /* 下拉选择器样式 */ .dropdown { position: relative; width: 100%; margin-bottom: 20rpx; } .dropdown-trigger { background-color: #f0f0f0; padding: 20rpx; border-radius: 8rpx; display: flex; justify-content: space-between; align-items: center; font-size: 28rpx; color: #333; } .dropdown-trigger .arrow { font-size: 24rpx; color: #999; } </style> 我想要去掉登录缓存功能
08-14
<template> <view class="container"> <!-- 登录区域 --> <view v-if="!isLoggedIn" class="login-box"> <view class="login-title">投诉后台管理登录</view> <input v-model="loginForm.username" placeholder="请输入账号" class="login-input" /> <input v-model="loginForm.password" placeholder="请输入密码" type="password" class="login-input" /> <button @click="login" class="login-button">登录</button> <button @click="goToHome" class="home-button">返回首页</button> <text v-if="loginError" class="login-error">{{ loginError }}</text> </view> <!-- 投诉列表区域 --> <view v-else class="complaint-container"> <view class="back-home" @click="goToHome"> <text class="icon">←</text> <text>返回首页</text> </view> <view class="search-bar"> <input v-model="searchForm.category" placeholder="请输入投诉类别" /> <input v-model="searchForm.keyword" placeholder="请输入关键词" /> <view class="dropdown"> <picker mode="selector" :range="statusOptions" range-key="label" :value="searchForm.statusIndex" @change="handleStatusPickerChange"> <view class="dropdown-trigger"> <text>{{ statusOptions[searchForm.statusIndex].label }}</text> <text class="arrow">▼</text> </view> </picker> </view> <button @click="searchComplaints">搜索</button> </view> <view class="complaint-list"> <view class="complaint-item" v-for="item in complaints" :key="item.id"> <view class="title">{{ item.title }}</view> <view class="category">类别:{{ item.category }}</view> <view class="status-container"> <text class="status-label">状态:</text> <picker mode="selector" :range="statusOptions" range-key="label" :value="item.statusIndex" @change="changeStatus($event, item)"> <view :class="['picker-button', getStatusClass(item.statusLabel)]"> <text>{{ item.statusLabel }}</text> </view> </picker> </view> </view> </view> </view> </view> </template> <script setup> import { ref } from 'vue'; // 登录相关 const isLoggedIn = ref(false); const loginForm = ref({ username: '', password: '' }); const loginError = ref(''); // 返回首页 const goToHome = () => { uni.switchTab({ url: '/pages/index/index' }); }; // 搜索相关 const searchForm = ref({ category: '', keyword: '', statusIndex: 0 // 默认选中“待处理” }); // 投诉列表 const complaints = ref([]); // 状态选择器事件 const handleStatusPickerChange = (event) => { const index = event.detail.value; searchForm.value.statusIndex = index; }; // 状态选项 const statusOptions = ref([ { label: '待处理', value: 0 }, { label: '处理中', value: 1 }, { label: '已完成', value: 2 } ]); //状态颜色 const getStatusClass = (statusLabel) => { if (statusLabel === '待处理') return 'status-pending'; if (statusLabel === '处理中') return 'status-processing'; if (statusLabel === '已完成') return 'status-completed'; return ''; }; // 模拟登录接口 const login = async () => { uni.showLoading({ title: '登录中' }); // 模拟请求接口 setTimeout(() => { if (loginForm.value.username === '' && loginForm.value.password === '') { isLoggedIn.value = true; loginError.value = ''; fetchComplaints(); // 登录成功后加载投诉列表 } else { loginError.value = '账号或密码错误'; } uni.hideLoading(); }, 500); }; // 获取投诉列表(模拟) const fetchComplaints = async () => { uni.showLoading({ title: '加载中' }); // 模拟从后台获取数据 setTimeout(() => { complaints.value = [ { id: 1, title: '关于食堂卫生问题的投诉', category: '后勤管理', content: '食堂卫生不达标,影响员工健康', status: 0, statusLabel: '待处理', statusIndex: 0 }, { id: 2, title: '关于办公室空调噪音大', category: '设备问题', content: '空调运行噪音大,影响办公', status: 1, statusLabel: '处理中', statusIndex: 1 } ]; uni.hideLoading(); }, 500); }; // 搜索投诉 const searchComplaints = async () => { uni.showLoading({ title: '搜索中' }); setTimeout(() => { let filtered = complaints.value; // 按类别过滤 if (searchForm.value.category) { filtered = filtered.filter(item => item.category.includes(searchForm.value.category)); } // 按关键词过滤 if (searchForm.value.keyword) { filtered = filtered.filter(item => item.content.includes(searchForm.value.keyword)); } // 按状态过滤 const selectedStatusValue = statusOptions.value[searchForm.value.statusIndex].value; if (selectedStatusValue !== '') { filtered = filtered.filter(item => item.status === selectedStatusValue); } complaints.value = filtered; uni.hideLoading(); }, 300); }; // 状态变更 const changeStatus = async (event, item) => { const index = event.detail.value; const newStatus = statusOptions.value[index].value; item.status = newStatus; item.statusLabel = statusOptions.value[index].label; item.statusIndex = index; // 模拟提交到后台 await updateStatusToServer(item); uni.showToast({ title: '状态已更新' }); }; // 模拟提交到后台 const updateStatusToServer = async (item) => { return new Promise(resolve => { setTimeout(() => { resolve(); }, 300); }); }; </script> <style scoped> .container { padding: 30rpx; background-color: #f9f9f9; } .home-button { background-color: #f0f0f0; color: #333; margin-top: 20rpx; } .top-bar { display: flex; align-items: center; padding: 20rpx 0; border-bottom: 1rpx solid #eee; margin-bottom: 30rpx; } .back-home { display: flex; align-items: center; font-size: 30rpx; color: #007AFF; padding: 10rpx 20rpx; border-radius: 8rpx; background-color: #f5f5f5; } .back-home .icon { margin-right: 10rpx; font-weight: bold; } .title { flex: 1; /* text-align: center; */ font-size: 34rpx; font-weight: bold; } .login-box { background-color: #fff; padding: 40rpx; border-radius: 16rpx; box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1); } .login-title { font-size: 36rpx; font-weight: bold; text-align: center; margin-bottom: 40rpx; color: #333; } .login-input { border: 1rpx solid #ccc; padding: 20rpx; margin-bottom: 30rpx; border-radius: 8rpx; width: 100%; } .login-button { background-color: #007AFF; color: white; } .login-error { color: red; font-size: 24rpx; margin-top: 10rpx; display: block; } .search-bar input { border: 1rpx solid #ccc; padding: 20rpx; margin-bottom: 20rpx; border-radius: 8rpx; } .complaint-list { margin-top: 30rpx; } .complaint-item { background-color: #fff; padding: 30rpx; margin-bottom: 30rpx; border-radius: 12rpx; box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.1); } .title { font-size: 32rpx; font-weight: bold; color: #333; margin-bottom: 20rpx; } .category { font-size: 28rpx; color: #666; margin-bottom: 20rpx; } .status { font-size: 28rpx; color: #999; } .status-container { display: flex; align-items: center; } .status-label { font-size: 28rpx; color: #999; } .picker-button { padding: 10rpx 20rpx; border-radius: 8rpx; font-size: 28rpx; color: white; } .status-pending { background-color: #ff9900; /* 橙色 */ } .status-processing { background-color: #007AFF; /* 蓝色 */ } .status-completed { background-color: #00cc66; /* 绿色 */ } /* 下拉选择器样式 */ .dropdown { position: relative; width: 100%; margin-bottom: 20rpx; } .dropdown-trigger { background-color: #f0f0f0; padding: 20rpx; border-radius: 8rpx; display: flex; justify-content: space-between; align-items: center; font-size: 28rpx; color: #333; } .dropdown-trigger .arrow { font-size: 24rpx; color: #999; } </style> 点击返回登录报错:Uncaught (in promise) {errMsg: 'switchTab:fail can not switch to no-tabBar page'} 参照其他页面返回上一页的代码:const goBack = () => { // 尝试使用正常的返回方法 try { const canBack = getCurrentPages().length > 1; if (canBack) { uni.navigateBack(); } else { // 没有页面历史时跳转到定页面 uni.reLaunch({ url: '/pages/ComplaintRecord/ComplaintRecord' }); } } catch (error) { // 异常时使用直接跳转 uni.reLaunch({ url: '/pages/ComplaintRecord/ComplaintRecord' }); } };返回首页本质就是返回上一页如果不能正常返回就跳转页面到首页:pages/index/index
08-14
<view class="container"> <view wx:if="{{isLoading}}" class="loading-mask"> <view class="loading-content"> <text class="loading-text">加载中...</text> </view> </view> <view wx:elif="{{errorMsg}}" class="error-content"> <text class="error-text">{{errorMsg}}</text> </view> <view wx:else> <!-- 顶部信息 --> <view class="header-section"> <view class="period-info"> <text class="period-title">历史时段: {{period}}</text> <text class="period-time">{{periodStartTime}} - {{periodEndTime}}</text> </view> <view class="train-info"> <text class="train-category">列车类: {{trainCategory}}</text> <text class="departure-time">出发时间: {{departureTime}}</text> <text class="time-interval">时段间隔: {{timeInterval}}分钟</text> </view> </view> <!-- 搜索框 --> <view class="search-section"> <view class="search-wrapper"> <input class="search-input" placeholder="搜索反馈..." bindinput="onSearchInput" /> <image class="search-icon" src="/images/search.png"></image> </view> </view> <!-- 反馈列表部分 --> <view class="feedback-list"> <view wx:if="{{filteredFeedbacks.length === 0}}" class="empty-feedback"> 暂无匹配的反馈数据 </view> <view wx:else> <view wx:for="{{filteredFeedbacks}}" wx:key="submitTime" class="feedback-item"> <view class="feedback-card"> <view class="card-header"> <view class="train-number">车次号: {{item.trainNumber}}</view> <view class="submit-time">提交时间: {{item.submitTime || item.saveTime}}</view> </view> <view class="card-body"> <view class="feedback-row"> <view class="label">车厢号:</view> <view class="value">{{item.carriageNumber || '无'}}</view> </view> <view class="feedback-row"> <view class="label">TSV:</view> <view class="value temperature-value" style="{{getTSVColor(item.tsvScore)}}"> {{item.tsvScore || 0}} </view> </view> <view class="feedback-row"> <view class="label">空气质量反馈:</view> <view class="value"> <block wx:if="{{item.airQualityFeedback && item.airQualityFeedback.length > 0}}"> <view class="air-quality-tags"> <text wx:for="{{item.airQualityFeedback}}" wx:key="index" class="tag-item"> {{item}} </text> </view> </block> <block wx:else> <text class="no-option">无</text> </block> </view> </view> </view> </view> </view> </view> </view> <!-- 统计部分 --> <view class="statistics-section"> <view class="section-title">车厢反馈统计:</view> <view wx:if="{{!carriageSatisfaction || Object.keys(carriageSatisfaction).length === 0}}" class="empty-statistics"> 暂无统计数据 </view> <view wx:else> <!-- 遍历 carriageSatisfaction --> <view wx:for="{{carriageSatisfaction}}" wx:key="carriageNumber" wx:for-item="stats" wx:for-index="carriageNumber" > <view class="carriage-card" style="{{getCarriageColor(carriageNumber)}}"> <view class="carriage-header"> <view class="carriage-number">车厢 {{carriageNumber}}</view> <view class="current-passengers"> 总人数: {{stats.total || '无数据'}} </view> </view> <view class="stats-group"> <view class="section-subtitle">TSV 统计:</view> <view class="stat-item"> <view class="stat-label">平均TSV:</view> <view class="stat-value" style="{{getTSVColor(stats.validAverageTSV)}}"> {{stats.validAverageTSV}} </view> </view> <view class="stat-item"> <view class="stat-label">反馈人数/总人数:</view> <view class="stat-value"> {{stats.feedbackCount || 0}} / {{stats.total || 0}} </view> </view> <view class="stat-item"> <view class="stat-label">反馈率:</view> <view class="stat-value"> {{stats.feedbackRate}} </view> </view> <view class="stat-item"> <view class="stat-label">座位数:</view> <view class="stat-value"> {{carriageStatistics[carriageNumber].seatCount || '无数据'}} </view> </view> <view class="stat-item"> <view class="stat-label">满载率:</view> <view class="stat-value {{stats.fullLoadRate > 80? 'high-load' : ''}}"> {{stats.fullLoadRate}} </view> </view> </view> <view class="stats-group"> <view class="section-subtitle">空气质量反馈:</view> <view class="air-quality-item"> <view class="air-quality-label">过于干燥:</view> <view class="air-quality-value"> {{carriageStatistics[carriageNumber].airQuality.tooDry || 0}} 人 ({{carriageStatistics[carriageNumber].airQuality.tooDryPercent || '0%'}}) </view> </view> <view class="air-quality-item"> <view class="air-quality-label">过于潮湿:</view> <view class="air-quality-value"> {{carriageStatistics[carriageNumber].airQuality.tooHumid || 0}} 人 ({{carriageStatistics[carriageNumber].airQuality.tooHumidPercent || '0%'}}) </view> </view> <view class="air-quality-item"> <view class="air-quality-label">空气有异味:</view> <view class="air-quality-value"> {{carriageStatistics[carriageNumber].airQuality.badSmell || 0}} 人 ({{carriageStatistics[carriageNumber].airQuality.badSmellPercent || '0%'}}) </view> </view> <view class="air-quality-item"> <view class="air-quality-label">无需改善:</view> <view class="air-quality-value"> {{carriageStatistics[carriageNumber].airQuality.noImprovementNeeded || 0}} 人 ({{carriageStatistics[carriageNumber].airQuality.noImprovementNeededPercent || '0%'}}) </view> </view> </view> <!-- 空气质量调整建议 --> <view class="stats-group air-quality-advice"> <view class="section-subtitle">空气质量调整建议:</view> <view class="advice-content"> <text class="advice-text"> {{calculateAirQualityAdvice(carriageNumber) || '无建议'}} </text> </view> </view> </view> </view> </view> </view> <!-- 返回按钮 --> <view class="back-button-section"> <button class="back-button" bindtap="navigateBackToCurrentPeriod"> 返回当前时段 </button> </view> </view> </view> 检查这段代码,查看车厢反馈统计的部分如何折叠车厢中的TSV 统计和空气质量反馈
08-23
标题基于Python的自主学习系统后端设计与实现AI更换标题第1章引言介绍自主学习系统的研究背景、意义、现状以及本文的研究方法和创新点。1.1研究背景与意义阐述自主学习系统在教育技术领域的重要性和应用价值。1.2国内外研究现状分析国内外在自主学习系统后端技术方面的研究进展。1.3研究方法与创新点概述本文采用Python技术栈的设计方法和系统创新点。第2章相关理论与技术总结自主学习系统后端开发的相关理论和技术基础。2.1自主学习系统理论阐述自主学习系统的定义、特征和理论基础。2.2Python后端技术栈介绍DjangoFlask等Python后端框架及其适用场景。2.3数据库技术讨论关系和非关系数据库在系统中的应用方案。第3章系统设计与实现详细介绍自主学习系统后端的设计方案和实现过程。3.1系统架构设计提出基于微服务的系统架构设计方案。3.2核心模块设计详细说明用户管理、学习资源管理、进度跟踪等核心模块设计。3.3关键技术实现阐述个性化推荐算法、学习行为分析等关键技术的实现。第4章系统测试与评估对系统进行功能测试和性能评估。4.1测试环境与方法介绍测试环境配置和采用的测试方法。4.2功能测试结果展示各功能模块的测试结果和问题修复情况。4.3性能评估分析分析系统在高并发等场景下的性能表现。第5章结论与展望总结研究成果并提出未来改进方向。5.1研究结论概括系统设计的主要成果和技术创新。5.2未来展望出系统局限性并提出后续优化方向。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值