diff between padding and margin

本文详细解释了CSS中边距(margin)和填充(padding)的概念及使用方法。边距是指元素边框与相邻元素之间的距离,而填充则是指元素边框与内容之间的空间。正确理解和运用这两者对于网页布局至关重要。

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

http://blog.webassist.com/2010/01/the-difference-between-css-margins-and-padding/

 

 

<template> <div class="quiz-container"> <div class="quiz-info"> <h1>知识问答挑战</h1> <div class="question-number">题目 {{ currentQuestionIndex + 1 }}/{{ totalQuestions }}</div> </div> <div class="progress-bar"> <div class="progress" :style="{width: progressWidth}"></div> </div> <!-- 核心:只渲染3个主要DOM元素 --> <!-- 1. 题目容器 --> <div class="question-container" v-once> <h2 class="question-title">{{ currentQuestion.text }}</h2> </div> <!-- 2. 选项容器 --> <div class="options-container"> <div v-for="(option, index) in currentQuestion.options" :key="index" class="option" :class="{selected: selectedOption === index}" @click="selectOption(index)" > <input type="radio" :id="'option'+index" :value="index" :checked="selectedOption === index" > <label :for="'option'+index"> <strong>{{ String.fromCharCode(65 + index) }}.</strong> {{ option.text }} </label> </div> </div> <!-- 3. 导航按钮容器 --> <div class="nav-buttons"> <button class="nav-btn prev-btn" :disabled="currentQuestionIndex === 0" @click="prevQuestion" > ← 上一题 </button> <div class="counter">已答:{{ answeredCount }}/{{ totalQuestions }}</div> <button class="nav-btn next-btn" :disabled="selectedOption === null" @click="nextQuestion" > {{ isLastQuestion ? '完成答题' : '下一题 →' }} </button> </div> </div> </div> </template> <script> export default { data: { questions: this.generateQuestions(50), currentQuestionIndex: 0, selectedOption: null, userAnswers: [], totalQuestions: 50 }, computed: { // 当前问题数据 currentQuestion() { return this.questions[this.currentQuestionIndex]; }, // 进度条宽度 progressWidth() { return `${((this.currentQuestionIndex + 1) / this.totalQuestions) * 100}%`; }, // 是否为最后一题 isLastQuestion() { return this.currentQuestionIndex === this.totalQuestions - 1; }, // 已答题目数量 answeredCount() { return this.userAnswers.filter(answer => answer !== null).length; } }, methods: { // 生成模拟题目数据 generateQuestions(count) { const questions = []; const topics = ['JavaScript', 'CSS', 'HTML', 'Vue.js', 'React', 'Node.js', 'HTTP协议', '算法']; const difficulty = ['简单', '中等', '困难']; for (let i = 0; i < count; i++) { const topic = topics[Math.floor(Math.random() * topics.length)]; const diff = difficulty[Math.floor(Math.random() * difficulty.length)]; questions.push({ id: i + 1, text: `以下关于${topic}的叙述中,哪项是${diff}级的知识点?`, options: [ { text: '正确选项', value: true }, { text: '干扰选项1', value: false }, { text: '干扰选项2', value: false }, { text: '干扰选项3', value: false } ] }); } return questions; }, // 选择选项 selectOption(index) { this.selectedOption = index; }, // 上一题 prevQuestion() { if (this.currentQuestionIndex > 0) { this.currentQuestionIndex--; // 恢复用户之前的选择(如果有) this.selectedOption = this.userAnswers[this.currentQuestionIndex]; } }, // 下一题 nextQuestion() { // 保存用户答案 this.userAnswers[this.currentQuestionIndex] = this.selectedOption; if (!this.isLastQuestion) { this.currentQuestionIndex++; // 重置选择状态,如果之前有答案则恢复 this.selectedOption = this.userAnswers[this.currentQuestionIndex] || null; } else { // 最后一题完成 this.showResults(); } }, // 显示结果 showResults() { const correctCount = this.userAnswers.reduce((count, selected, index) => { return count + (selected !== null && this.questions[index].options[selected].value ? 1 : 0); }, 0); alert(`答题完成!\n共答对 ${correctCount} 题\n正确率: ${(correctCount/this.totalQuestions*100).toFixed(1)}%`); // 重置测试 this.currentQuestionIndex = 0; this.userAnswers = []; this.selectedOption = null; } } } </script> <style> * { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Microsoft YaHei', sans-serif; } body { background-color: #f5f7fa; padding: 20px; } .quiz-container { max-width: 800px; margin: 0 auto; background-color: #fff; border-radius: 10px; box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08); overflow: hidden; padding: 25px; position: relative; } .progress-bar { height: 8px; background-color: #e9ecef; border-radius: 4px; margin-bottom: 25px; position: relative; overflow: hidden; } .progress { height: 100%; background: linear-gradient(90deg, #4c6ef5, #228be6); transition: width 0.4s ease; } .question-container { background-color: #f8f9fa; border-radius: 8px; padding: 20px; margin-bottom: 25px; min-height: 150px; transition: all 0.4s ease; } .question-title { font-size: 18px; color: #343a40; line-height: 1.6; margin-bottom: 20px; } .options-container { display: flex; flex-direction: column; gap: 15px; } .option { display: flex; align-items: center; background: white; border: 2px solid #e9ecef; border-radius: 8px; padding: 14px 20px; cursor: pointer; transition: all 0.2s; } .option:hover { background-color: #f1f3f5; border-color: #ced4da; } .option.selected { background-color: #edf2ff; border-color: #4c6ef5; } .option input { margin-right: 15px; cursor: pointer; } .option label { cursor: pointer; font-size: 16px; color: #495057; flex-grow: 1; } .nav-buttons { display: flex; justify-content: space-between; align-items: center; } .nav-btn { padding: 12px 25px; background-color: #4263eb; color: white; border: none; border-radius: 6px; font-size: 16px; font-weight: 500; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; } .nav-btn:hover { background-color: #3b5bdb; transform: translateY(-2px); } .nav-btn:disabled { background-color: #adb5bd; cursor: not-allowed; transform: none; } .prev-btn { background-color: #868e96; } .prev-btn:hover { background-color: #495057; } .counter { font-size: 15px; color: #868e96; } .quiz-info { margin-bottom: 15px; display: flex; justify-content: space-between; align-items: center; } .question-number { font-weight: bold; color: #4263eb; font-size: 16px; } </style> 修改一下
06-07
[plugin:vite:import-analysis] Failed to resolve import "@dcloudio/uni-ui/lib/uni-loading/uni-loading.vue" from "E:/SmCity/pages/Subway/Subway.vue". Does the file exist? 19:57:32.237 at pages/Subway/Subway.vue:131:9 19:57:32.240 1 | import __easycom_0 from '@dcloudio/uni-ui/lib/uni-search-bar/uni-search-bar.vue';import { resolveDynamicComponent as __resolveDynamicComponent } from 'vue';import { resolveEasycom } from '@dcloudio/uni-app';import '@dcloudio/uni-components/style/text.css';import { Text as __syscom_1 } from '@dcloudio/uni-h5';import __easycom_2 from '@dcloudio/uni-ui/lib/uni-icons/uni-icons.vue';import '@dcloudio/uni-components/style/view.css';import { View as __syscom_3 } from '@dcloudio/uni-h5';import '@dcloudio/uni-components/style/scroll-view.css';import '@dcloudio/uni-components/style/refresher.css';import { ScrollView as __syscom_4 } from '@dcloudio/uni-h5';import __easycom_5 from '@dcloudio/uni-ui/lib/uni-popup/uni-popup.vue';import __easycom_6 from 'E:/SmCity/components/ScBuysList/ScBuysList.vue';import '@dcloudio/uni-components/style/input.css';import { Input as __syscom_7 } from '@dcloudio/uni-h5';import '@dcloudio/uni-components/style/button.css';import { Button as __syscom_8 } from '@dcloudio/uni-h5';import __easycom_9 from '@dcloudio/uni-ui/lib/uni-loading/uni-loading.vue';import '@dcloudio/uni-components/style/radio.css';import { Radio as __syscom_10 } from '@dcloudio/uni-h5';import '@dcloudio/uni-components/style/label.css';import { Label as __syscom_11 } from '@dcloudio/uni-h5';import '@dcloudio/uni-components/style/radio-group.css';import { RadioGroup as __syscom_12 } from '@dcloudio/uni-h5';import { 19:57:32.240 | ^ 19:57:32.240 2 | computed, 19:57:32.240 3 | ref, 19:57:32.296 [Vue warn]: Unhandled error during execution of async component loader \n at <AsyncComponentWrapper>\nat <PageBody>\nat <Page>\nat <Anonymous>\nat <KeepAlive>\nat <RouterView>\nat <Layout>\nat <App> 19:57:32.298 ‍[⁠TypeError⁠]‍ {message: "Failed to fetch dynamically imported module: http:…host:5173/pages/Subway/Subway.vue?t=1750161451638"} <template> <view class="bus-wrap"> <!-- 搜索栏 --> <uni-search-bar placeholder="搜索站点" ref="searchbar" @confirm="search"></uni-search-bar> <uni-popup ref="popup" type="bottom" background-color="#fff"> <view class="popup-content"> <view class="popup-header"> <text class="popup-title">搜索结果</text> <uni-icons type="closeempty" size="24" color="#999" @click="closePopup"></uni-icons> </view> <scroll-view scroll-y class="result-list"> <view v-if="searchData.length === 0" class="empty-result"> <text>未找到相关站点</text> </view> <view v-for="(result, index) in searchData" :key="index" class="result-item"> <text class="result-name">{{ result.name }}</text> <text class="result-line">可乘坐: {{ result.linesId }}号线</text> </view> </scroll-view> </view> </uni-popup> <!-- 原有站点信息区域--> <view class="bus-stops" style="height: 600rpx; overflow-y: scroll;"> <view v-for="(stop, index) in busStops" :key="stop.stepsId" class="stop-item" :style="{ backgroundColor: index % 2 === 0 ? '#52a5f8' : '#0066FF' }"> <text class="stop-name">{{ stop.name }}</text> <text class="stop-sequence">乘坐: {{ stop.linesId }}号线</text> </view> </view> <!-- 原有站点路线 --> <ScBuysList>> <template #itemSlot="item"> <view class="info" @click="gotoDetail(item.id)"> <text class="title">{{ item.name }}</text> <text class="details">起点: {{ item.first }}, 终点: {{ item.end }}</text> </view> <view class="price">价格: ¥{{ item.price }}</view> </template> </ScBuysList> <!-- 新增订单创建区域 --> <view class="order-section"> <view class="section-title"> <text>创建巴士订单</text> </view> <view class="form-item"> <text class="label">起点</text> <input class="input" v-model="orderForm.start" placeholder="请输入起点" /> </view> <view class="form-item"> <text class="label">终点</text> <input class="input" v-model="orderForm.end" placeholder="请输入终点" /> </view> <view class="form-item"> <text class="label">路线</text> <input class="input" v-model="orderForm.path" placeholder="请输入路线" /> </view> <view class="form-item"> <text class="label">价格</text> <input class="input" v-model="orderForm.price" placeholder="请输入价格" type="number" /> </view> <button class="submit-btn" @click="createOrder">提交订单</button> </view> <!-- 订单列表区域 --> <view class="order-list-section"> <view class="section-title"> <text>我的订单</text> <button class="refresh-btn" @click="fetchOrders"> <uni-icons type="refresh" size="16" color="#4a90e2"></uni-icons> <text>刷新</text> </button> </view> <view v-if="orderLoading" class="loading"> <uni-loading type="circle" color="#4a90e2"></uni-loading> </view> <view v-else-if="orders.length === 0" class="empty"> <text>暂无订单记录</text> </view> <view v-else class="orders-container"> <view v-for="order in orders" :key="order.id" class="order-item"> <view class="order-header"> <text class="order-number">订单号: {{ order.orderNum }}</text> <text class="order-status" :class="getStatusClass(order.status)"> {{ getStatusText(order.status) }} </text> </view> <view class="order-content"> <text class="route">{{ order.path }}: {{ order.start }} → {{ order.end }}</text> <text class="price">¥{{ order.price }}</text> </view> <view v-if="order.status === 0" class="order-actions"> <button class="pay-btn" @click="showPayPopup(order)">支付</button> <button class="cancel-btn" @click="cancelOrder(order.id)">取消</button> </view> </view> </view> </view> <!-- 支付弹窗 --> <uni-popup ref="payPopup" type="bottom" background-color="#fff"> <view class="pay-popup"> <view class="popup-header"> <text class="popup-title">订单支付</text> <uni-icons type="closeempty" size="24" color="#999" @click="closePayPopup"></uni-icons> </view> <view class="pay-content"> <text class="order-number">订单号: {{ currentOrder.orderNum }}</text> <text class="pay-amount">支付金额: ¥{{ currentOrder.price }}</text> <radio-group class="payment-methods" @change="handlePaymentMethodChange"> <label class="payment-method"> <radio value="wechat" checked /> <text>微信支付</text> </label> <label class="payment-method"> <radio value="alipay" /> <text>支付宝</text> </label> </radio-group> <button class="confirm-pay-btn" @click="payOrder">确认支付</button> </view> </view> </uni-popup> </view> </template> <script setup> import { computed, ref, onMounted } from 'vue'; import { ip, getHttp } from '../../utils/http.js'; import { onLoad } from '@dcloudio/uni-app' // 站点信息相关数据 const busStops = ref([]); const linesId = ref(); const stepsId = ref(); const searchbar = ref(null) const popup = ref(null) const searchData = ref([]) //订单 const busOrder = ref() // 关闭弹窗 const closePopup = () => { popup.value.close() } // 搜索事件 const search = (e) => { searchData.value = [] console.log('搜索关键字: ' + e.value); const keyword = e.value.trim(); // 去除前后空格 for (let i = 0; i < busStops.value.length; i++) { const stop = busStops.value[i]; if (stop.name.includes(keyword)) { searchData.value.push({ linesId: stop.linesId, name: stop.name }); } } console.log('搜索结果:', searchData.value); popup.value.open() searchbar.value.cancel() } // 获取站点信息 async function getBusStops() { const result = await getHttp({ url: '/prod-api/api/bus/stop/list', data: { stepsId:stepsId.value, name:name.value, linesId: linesId.value } }); busStops.value = result.data.rows; console.log('站点信息:', busStops.value); } // 在组件挂载时调用获取站点信息的函数 onMounted(() => { getBusStops(); }); // 跳转至路线详情 const gotoDetail = (id) => { uni.navigateTo({ url: '/pages/Subway/BuysDetail?id=' + id }); } // 订单相关数据 const orderForm = ref({ start: '', end: '', path: '', price: '', status: 0 }); const orders = ref([]); const orderLoading = ref(false); const payPopup = ref(null); const currentOrder = ref({}); const paymentType = ref('wechat'); // 创建订单 const createOrder = async () => { if (!orderForm.value.start || !orderForm.value.end || !orderForm.value.path || !orderForm.value.price) { return uni.showToast({ title: '请填写完整订单信息', icon: 'none' }); } try { const result = await getHttp({ url: '/prod-api/api/bus/order', data: { start: orderForm.value.start, end: orderForm.value.end, path: orderForm.value.path, price: Number(orderForm.value.price), status: 0 } }); uni.showToast({ title: '订单创建成功', icon: 'success' }); // 重置表单 orderForm.value = { start: '', end: '', path: '', price: '', status: 0 }; // 刷新订单列表 fetchOrders(); } catch (error) { uni.showToast({ title: error.data?.msg || '订单创建失败', icon: 'none' }); } }; // 获取订单列表 const fetchOrders = async () => { orderLoading.value = true; try { const result = await getHttp({ url: '/prod-api/api/bus/order/list', params: { pageNum: 1, pageSize: 10 } }); orders.value = result.data.rows || []; } catch (error) { uni.showToast({ title: error.data?.msg || '获取订单失败', icon: 'none' }); } finally { orderLoading.value = false; } }; // 支付订单 const showPayPopup = (order) => { currentOrder.value = order; payPopup.value.open(); }; const closePayPopup = () => { payPopup.value.close(); }; const handlePaymentMethodChange = (e) => { paymentType.value = e.detail.value; }; const payOrder = async () => { try { const result = await getHttp({ url: '/prod-api/api/bus/pay', data: { orderNum: currentOrder.value.orderNum, paymentType: paymentType.value } }); uni.showToast({ title: '支付成功', icon: 'success' }); closePayPopup(); fetchOrders(); } catch (error) { uni.showToast({ title: error.data?.msg || '支付失败', icon: 'none' }); } }; // 取消订单 const cancelOrder = async (orderId) => { try { uni.showLoading({ title: '处理中...' }); await postHttp({ url: '/prod-api/api/bus/order/cancel', data: { orderId } }); uni.showToast({ title: '订单已取消', icon: 'success' }); fetchOrders(); } catch (error) { uni.showToast({ title: error.data?.msg || '取消失败', icon: 'none' }); } finally { uni.hideLoading(); } }; // 状态显示 const getStatusText = (status) => { const statusMap = { 0: '待支付', 1: '已支付', 2: '已完成', 3: '已取消' }; return statusMap[status] || '未知'; }; const getStatusClass = (status) => { const classMap = { 0: 'status-pending', 1: 'status-paid', 2: 'status-completed', 3: 'status-canceled' }; return classMap[status] || ''; }; // 初始化 onMounted(() => { fetchOrders(); }); </script> <style lang="scss" scoped> /* 新增弹窗样式 */ .popup-content { padding: 30rpx; .popup-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30rpx; .popup-title { font-size: 36rpx; font-weight: bold; color: #333; } } .result-list { max-height: 60vh; .empty-result { padding: 30rpx; text-align: center; color: #999; } .result-item { padding: 20rpx; border-bottom: 1rpx solid #eee; .result-name { display: block; font-size: 32rpx; color: #333; margin-bottom: 10rpx; } .result-line { font-size: 28rpx; color: #666; } } } } .bus-wrap { padding: 20rpx; background-color: #f0f8ff; } .bus-stops { overflow-y: scroll; margin: 20rpx 0; padding: 20rpx; background-color: #ffffff; border-radius: 16rpx; box-shadow: 0rpx 4rpx 8rpx rgba(0, 0, 0, 0.1); .stop-item { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 0; border-bottom: 1px solid rgba(255, 255, 255, 0.3); &:last-child { border-bottom: none; } .stop-name { font-size: 32rpx; color: #fff; } .stop-sequence { font-size: 28rpx; color: #fff; } } .highlight { color: #ff9800; } } /* 新增订单相关样式 */ .order-section, .order-list-section { background-color: #fff; border-radius: 16rpx; padding: 30rpx; margin: 20rpx 0; box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05); .section-title { font-size: 32rpx; font-weight: bold; color: #333; margin-bottom: 20rpx; display: flex; justify-content: space-between; align-items: center; } } .form-item { margin-bottom: 20rpx; .label { display: block; font-size: 28rpx; color: #666; margin-bottom: 10rpx; } .input { width: 100%; padding: 20rpx; border: 1rpx solid #ddd; border-radius: 8rpx; font-size: 28rpx; } } .submit-btn, .confirm-pay-btn { background-color: #4a90e2; color: #fff; border-radius: 50rpx; font-size: 30rpx; margin-top: 20rpx; } .order-item { padding: 20rpx 0; border-bottom: 1rpx solid #eee; &:last-child { border-bottom: none; } } .order-header { display: flex; justify-content: space-between; margin-bottom: 15rpx; } .order-status { font-size: 26rpx; padding: 4rpx 12rpx; border-radius: 20rpx; &.status-pending { color: #f39c12; background-color: #fff4e5; } &.status-paid { color: #2ecc71; background-color: #e8f8f0; } } .order-actions { display: flex; justify-content: flex-end; margin-top: 20rpx; button { margin-left: 20rpx; font-size: 26rpx; padding: 10rpx 20rpx; border-radius: 30rpx; &.pay-btn { background-color: #4a90e2; color: #fff; } &.cancel-btn { background-color: #fff; color: #666; border: 1rpx solid #ddd; } } } .loading { display: flex; justify-content: center; padding: 50rpx 0; } .empty { text-align: center; padding: 50rpx 0; color: #999; } .pay-popup { padding: 30rpx; .pay-amount { display: block; font-size: 36rpx; font-weight: bold; color: #ff6b6b; margin: 20rpx 0; } .payment-method { display: flex; align-items: center; padding: 20rpx 0; border-bottom: 1rpx solid #eee; } } </style> <template> <view class="buys"> <!-- 新闻列表 --> <view class="list"> <view class="buysitem" v-for="item in currentBuysList" :key="item.id" @click="toBuysDetail(item.id)"> <slot name="itemSlot" v-bind="item"></slot> </view> </view> </view> </template> <script setup> import { computed, ref } from 'vue'; import { ip, getHttp } from '../../utils/http.js' //路线列表 const buysList=ref([]) //当前路线列表内容 const currentBuysList=ref([]) //全部路线列表 async function getBuysList() { const result = await getHttp({ url: '/prod-api/api/bus/line/list' }) buysList.value = result.data.rows currentBuysList.value = buysList.value } //跳转路线详情页面 const toBuysDetail=(id)=>{ uni.navigateTo({ url:'/pages/Subway/Subway?id='+id }) } getBuysList() </script> <style lang="scss"> .buys { padding: 20rpx; background-color: #f5f5f5; } .list { display: flex; flex-direction: column; gap: 20rpx; } .buysitem { background-color: #fff; border-radius: 16rpx; box-shadow: 0rpx 4rpx 8rpx rgba(0, 0, 0, 0.1); padding: 20rpx; display: flex; align-items: center; justify-content: space-between; transition: transform 0.2s; &:hover { transform: scale(1.0); } .info { flex: 1; margin-right: 20rpx; .title { font-size: 29rpx; color: #333; margin-bottom: 10rpx; } .details { font-size: 26rpx; color: #666; text { display: block; margin: 5rpx 0; } } } .price { font-size: 32rpx; color: #ff6600; font-weight: bold; } } </style>
06-18
<template> <view class="container"> <!-- 顶部固定区域 --> <view class="header-section"> <view class="banner-section"> <!-- 修复:使用英文双引号 --> <image class="banner-image" :src="bannerData.imageUrl" /> </view> <view class="title">{{ bannerData.title }}</view> </view> <!-- 分隔线 --> <view class="section-divider"></view> <!-- 内容包装器 --> <view class="content-wrapper"> <!-- 可滚动区域 --> <view class="scroll-container"> <scroll-view scroll-y="true" :enhanced="true" :show-scrollbar="false" class="scroll-view" > <view v-for="item in newsList" :key="item.id" class="news-item" @click="navigateToDetail(item)" > <view class="news-content"> <text class="news-title">{{ item.title }}</text> <text class="news-summary">{{ item.summary }}</text> <text class="news-date">{{ item.publishDate }}</text> </view> <view class="status-box" :class="item.read ? 'read' : 'unread'" > {{ item.read ? '已阅' : '未阅' }} </view> </view> <!-- 加载状态提示 --> <!-- 修复:使用统一的 loading 变量 --> <view v-if="listLoading" class="loading-text">加载中...</view> <view v-if="!listLoading && newsList.length === 0" class="no-data">暂无数据</view> </scroll-view> </view> </view> <!-- 分页组件 --> <view class="pagination"> <!-- 每页条数选择器 --> <view class="page-size-selector"> <picker :value="pageSizeIndex" :range="pageSizeOptions" range-key="label" @change="changePageSize" > <view class="selector-box"> <text class="selector-text">{{ pageSize }}条/页</text> <text class="selector-icon">▼</text> </view> </picker> </view> <!-- 分页控制 --> <view class="page-controls"> <button class="page-btn prev-btn" :disabled="currentPage === 1" @click="goToPage(currentPage - 1)" > < </button> <view class="page-info"> <input type="number" v-model="currentPage" class="page-input" :min="1" :max="totalPages" @blur="validatePage" /> <text class="page-total">/ {{ totalPages }}</text> </view> <button class="page-btn next-btn" :disabled="currentPage >= totalPages" @click="goToPage(currentPage + 1)" > > </button> </view> <!-- 跳转按钮 --> <button class="go-btn" @click="validatePage">跳转</button> </view> </view> </template> <script setup> import { ref, onMounted, computed, watch } from 'vue'; // 顶部横幅数据 const bannerData = ref({ title: '', imageUrl: '' }); // 新闻列表数据 const newsList = ref([]); // 修复:使用统一的加载状态变量 const listLoading = ref(false); // 分页相关数据 const currentPage = ref(1); const pageSize = ref(10); const total = ref(0); // 分页选项配置 const pageSizeOptions = ref([ { value: 5, label: '5条/页' }, { value: 10, label: '10条/页' }, { value: 15, label: '15条/页' }, { value: 20, label: '20条/页' } ]); // 计算属性 const pageSizeIndex = computed(() => pageSizeOptions.value.findIndex(opt => opt.value === pageSize.value) ); const totalPages = computed(() => { return Math.ceil(total.value / pageSize.value) || 1; }); // 监听页码变化 watch([currentPage, pageSize], () => { fetchData(); }); // 获取顶部横幅数据 const fetchBanners = () => { listLoading.value = true; uni.request({ url: '/api/incorruptFront/culture/index', method: 'POST', success: (res) => { if (res.statusCode === 200 && res.data.code === 200) { bannerData.value = { title: res.data.data.title, imageUrl: res.data.data.imageUrl }; } else { uni.showToast({ title: res.data?.msg || '请求失败', icon: 'none' }); } }, fail: (err) => { uni.showToast({ title: '网络错误', icon: 'error' }); console.error('请求失败:', err); }, complete: () => { listLoading.value = false; } }); }; // 获取廉洁文化资讯列表 const fetchData = () => { listLoading.value = true; uni.request({ url: '/api/incorruptFront/frontArticle/list', method: 'GET', data: { pageNum: currentPage.value, pageSize: pageSize.value }, success: (res) => { if (res.statusCode === 200 && res.data.code === 200) { newsList.value = res.data.rows.map(item => ({ id: item.articleId, title: item.title, summary: item.articleDescribe, publishDate: item.publishDate, read: Math.random() > 0.5 // 模拟阅读状态 })); total.value = res.data.total; } else { uni.showToast({ title: res.data?.msg || '获取数据失败', icon: 'none' }); } }, fail: (err) => { uni.showToast({ title: '网络错误', icon: 'error' }); console.error('请求失败:', err); }, complete: () => { listLoading.value = false; } }); }; // 改变每页条数 const changePageSize = (e) => { const index = e.detail.value; pageSize.value = pageSizeOptions.value[index].value; currentPage.value = 1; }; // 跳转到指定页码 const goToPage = (page) => { if (page < 1 || page > totalPages.value) return; currentPage.value = page; }; // 验证页码 const validatePage = () => { if (currentPage.value < 1) currentPage.value = 1; if (currentPage.value > totalPages.value) currentPage.value = totalPages.value; }; // 跳转详情页 const navigateToDetail = (item) => { uni.navigateTo({ url: `/pages/IntegrityCulture/IntegrityCultureDetail/IntegrityCultureDetail?articleId=${item.id}` }); }; onMounted(() => { fetchBanners(); fetchData(); }); </script> <style scoped> /* 整体容器 - 禁止滚动 */ .container { padding: 30rpx; background-color: #f9f9f9; height: 100vh; overflow: hidden; box-sizing: border-box; display: flex; flex-direction: column; } /* 顶部固定区域 */ .header-section { flex-shrink: 0; margin-bottom: 20rpx; } .banner-section { border-radius: 16rpx; overflow: hidden; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1); } .banner-image { width: 100%; height: 320rpx; display: block; object-fit: cover; } .title { font-size: 36rpx; font-weight: bold; text-align: center; margin: 20rpx 0; color: #2c3e50; position: relative; padding-top: 20rpx; } .title::before { content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 60rpx; height: 6rpx; background: linear-gradient(to right, #4caf50, #2196f3, #4caf50); border-radius: 3rpx; } /* 分隔线 */ .section-divider { height: 1rpx; background: linear-gradient(to right, #4caf50, #2196f3, #4caf50); margin: 10rpx 0 20rpx; opacity: 0.2; } /* 内容包装器 */ .content-wrapper { flex: 1; display: flex; flex-direction: column; min-height: 0; } /* 滚动区域容器 */ .scroll-container { flex: 1; min-height: 0; display: flex; flex-direction: column; background-color: #fff; border-radius: 16rpx; overflow: hidden; box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05); } /* 滚动视图 */ .scroll-view { flex: 1; height: 100%; } /* 隐藏滚动条 */ .scroll-view ::-webkit-scrollbar { display: none; width: 0; height: 0; color: transparent; } /* 新闻项样式 */ .news-item { padding: 30rpx; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1rpx solid #eee; transition: background-color 0.2s; position: relative; } .news-item:active { background-color: #f5f7fa; } .news-content { flex: 1; padding-right: 20rpx; } .news-title { font-size: 32rpx; font-weight: bold; color: #333; display: block; margin-bottom: 10rpx; } .news-summary { font-size: 28rpx; color: #666; display: block; margin-bottom: 10rpx; line-height: 1.5; } .news-date { font-size: 24rpx; color: #999; display: block; } .status-box { padding: 8rpx 16rpx; font-size: 24rpx; border-radius: 8rpx; min-width: 80rpx; text-align: center; flex-shrink: 0; align-self: flex-start; } .status-box.read { background-color: rgba(76, 175, 80, 0.1); color: #4caf50; } .status-box.unread { background-color: rgba(244, 67, 54, 0.1); color: #f44336; } /* 加载状态 */ .loading-text, .no-data { text-align: center; padding: 30rpx; font-size: 28rpx; color: #999; } /* 分页样式 */ .pagination { display: flex; align-items: center; justify-content: space-between; padding: 12rpx 20rpx; background-color: #fff; border-radius: 16rpx; height: 80rpx; box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05); margin-top: 20rpx; flex-shrink: 0; } /* 每页选择器样式 */ .page-size-selector { flex: 0 0 auto; } .selector-box { display: flex; align-items: center; padding: 0 20rpx; height: 56rpx; background-color: #f5f7fa; border-radius: 40rpx; font-size: 24rpx; } .selector-text { color: #333; margin-right: 8rpx; } .selector-icon { font-size: 20rpx; color: #666; } /* 分页控制区域 */ .page-controls { display: flex; align-items: center; margin: 0 15rpx; flex: 1; justify-content: center; } /* 页码按钮样式 */ .page-btn { display: flex; align-items: center; justify-content: center; width: 60rpx; height: 60rpx; padding: 0; margin: 0 5rpx; background-color: #f5f7fa; border-radius: 50%; font-size: 32rpx; line-height: 1; } .prev-btn, .next-btn { background-color: #4caf50; color: white; } .page-btn:disabled { background-color: #f0f0f0; color: #cccccc; } /* 页码信息样式 */ .page-info { display: flex; align-items: center; margin: 0 15rpx; } .page-input { width: 80rpx; height: 50rpx; border: 1rpx solid #ddd; border-radius: 8rpx; padding: 0 10rpx; text-align: center; font-size: 28rpx; background-color: #fff; } .page-total { font-size: 24rpx; color: #666; margin-left: 5rpx; } /* 跳转按钮 */ .go-btn { padding: 0 20rpx; height: 56rpx; background-color: #2196f3; color: white; border-radius: 40rpx; font-size: 24rpx; line-height: 56rpx; } /* 响应式调整 */ @media (max-height: 700px) { .banner-image { height: 240rpx; } .title { font-size: 32rpx; margin: 15rpx 0; } .news-item { padding: 20rpx; } .pagination { height: 70rpx; } } @media (max-width: 480px) { .container { padding: 20rpx; } .pagination { padding: 10rpx; } .selector-text { font-size: 22rpx; } .page-input { width: 70rpx; font-size: 24rpx; } .go-btn { padding: 0 15rpx; font-size: 22rpx; } .news-title { font-size: 30rpx; } .news-summary { font-size: 26rpx; } } </style> 这个列表页调用接口获取到的数据内容如下:{ "total": 9, "rows": [ { "createBy": null, "createTime": "2025-08-18 15:45:46", "updateBy": null, "updateTime": "2025-08-18 18:24:37", "remark": null, "articleId": 14, "title": "22", "publishDate": "2025-08-12", "articleDescribe": "22", "content": "222222", "status": "0" }, { "createBy": null, "createTime": "2025-08-18 18:24:55", "updateBy": null, "updateTime": null, "remark": null, "articleId": 15, "title": "2233", "publishDate": "2025-08-18", "articleDescribe": "333", "content": "3333", "status": "0" }, { "createBy": null, "createTime": "2025-08-18 18:25:13", "updateBy": null, "updateTime": null, "remark": null, "articleId": 16, "title": "444", "publishDate": "2025-08-18", "articleDescribe": "444", "content": "444", "status": "0" }, { "createBy": null, "createTime": "2025-08-18 18:25:44", "updateBy": null, "updateTime": null, "remark": null, "articleId": 17, "title": "333", "publishDate": "2025-08-18", "articleDescribe": "333", "content": "3333", "status": "0" }, { "createBy": null, "createTime": "2025-08-18 18:28:56", "updateBy": null, "updateTime": "2025-08-18 18:30:52", "remark": null, "articleId": 18, "title": "55", "publishDate": "2025-08-18", "articleDescribe": "555", "content": "555", "status": "1" }, { "createBy": null, "createTime": "2025-08-18 18:38:58", "updateBy": null, "updateTime": null, "remark": null, "articleId": 19, "title": "66", "publishDate": "2025-08-18", "articleDescribe": "666", "content": "666", "status": "0" }, { "createBy": null, "createTime": "2025-08-18 18:40:20", "updateBy": null, "updateTime": null, "remark": null, "articleId": 20, "title": "77", "publishDate": "2025-08-18", "articleDescribe": "777", "content": "777", "status": "0" }, { "createBy": null, "createTime": "2025-08-18 18:41:56", "updateBy": null, "updateTime": null, "remark": null, "articleId": 21, "title": "888", "publishDate": "2025-08-18", "articleDescribe": "888", "content": "888", "status": "0" }, { "createBy": null, "createTime": "2025-08-18 18:42:12", "updateBy": null, "updateTime": "2025-08-19 16:42:44", "remark": null, "articleId": 22, "title": "99", "publishDate": "2025-08-18", "articleDescribe": "999", "content": "999", "status": "1" } ], "code": 200, "msg": "查询成功" }我想要点击列表跳转详情页的时候把该列表的articleId传到详情页,让详情页获取这个ID
08-22
内容概要:该论文聚焦于T2WI核磁共振图像超分辨率问题,提出了一种利用T1WI模态作为辅助信息的跨模态解决方案。其主要贡献包括:提出基于高频信息约束的网络框架,通过主干特征提取分支和高频结构先验建模分支结合Transformer模块和注意力机制有效重建高频细节;设计渐进式特征匹配融合框架,采用多阶段相似特征匹配算法提高匹配鲁棒性;引入模型量化技术降低推理资源需求。实验结果表明,该方法不仅提高了超分辨率性能,还保持了图像质量。 适合人群:从事医学图像处理、计算机视觉领域的研究人员和工程师,尤其是对核磁共振图像超分辨率感兴趣的学者和技术开发者。 使用场景及目标:①适用于需要提升T2WI核磁共振图像分辨率的应用场景;②目标是通过跨模态信息融合提高图像质量,解决传统单模态方法难以克服的高频细节丢失问题;③为临床诊断提供更高质量的影像资料,帮助医生更准确地识别病灶。 其他说明:论文不仅提供了详细的网络架构设计与实现代码,还深入探讨了跨模态噪声的本质、高频信息约束的实现方式以及渐进式特征匹配的具体过程。此外,作者还对模型进行了量化处理,使得该方法可以在资源受限环境下高效运行。阅读时应重点关注论文中提到的技术创新点及其背后的原理,理解如何通过跨模态信息融合提升图像重建效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值